4 ms·
>If I want to know how much memory to allocate, bytes are it. If I want to know how much screen space to allocate, font rendering metrics are it. If I want to d
by coldtea 9y ago
>If I want to know how much memory to allocate, bytes are it. If I want to know how much screen space to allocate, font rendering metrics are it. If I want to do word-breaking, grapheme clusters are it.
Size in memory/bytes you could get trivially for any string (and this doesn't change with whether you chose bytes, graphemes or code points or whatever to iterate).
Screen space is irrelevant/orthogonal to encoding -- it appears at the font level and the font rendering engine that will give the metrics will accept whatever encoding it is.
- Retra 9y ago>Screen space is irrelevant/orthogonal to encoding Exactly. That's why measurements of string length shouldn't ever assume I'm looking for a unit-of-offset for a monospaced font. The problem is that most naive programmers think that's what a string length is and should be.