Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Who Knew Email Subjects Are So Complicated.
Something like
encoded_length = 4 * ceil(length / 3) + len(prefix + suffix)
cut_at = floor((desired_length - len(prefix+suffix) / 4) * 3
Then, you should also try to at least cut on a utf8 code-point boundary and maybe handle the whole unicode grapheme something something.
Something like
encoded_length = 4 * ceil(length / 3) + len(prefix + suffix)
cut_at = floor((desired_length - len(prefix+suffix) / 4) * 3
Then, you should also try to at least cut on a utf8 code-point boundary and maybe handle the whole unicode grapheme something something.