News for hackers. Stuff that matters.
Re:Who Knew Email Subjects Are So Complicated by labawi on Thursday June 10, 2021 @03:37PM (#27464696)
Doesn't base64 have a simple closed-form formula for the expansion, which can be easily inverted for a single-step calculation of max source length?

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.

Re:Who Knew Email Subjects Are So Complicated by micahzayner on Thursday June 10, 2021 @04:55PM (#27465693)
interesting
Re:Who Knew Email Subjects Are So Complicated by suhas_rd on Thursday June 10, 2021 @02:24PM (#27463786)
well written and insightful. Thank you for sharing your learning.
Re:Who Knew Email Subjects Are So Complicated by natSand on Thursday June 10, 2021 @02:38PM (#27463956)
great article!