9 ms·
> non UTF-8 encoded strings on input/output I would just use UTF-8 everywhere.
by codedokode 3mo ago
> non UTF-8 encoded strings on input/output
I would just use UTF-8 everywhere.
- rswail 3mo agoStoring them as 32 bits wide in memory means you can at least index by a codepoint (if not a glyph).
- codedokode 3mo agoI think you rarely need it. May I know what is your usecase that you need this often?
- rswail 3mo agoExtract the nth grapheme from a string of Unicode codepoints. Codepoints are 32-bit values. Take into account that some Unicode codepoints work together to combine to form a grapheme which then links to a glyph for display. If you use UTF-8 internally, you will be expanding out to full 32 bits when scanning the vector anyway. So if memory isn't an issue (and most of the time it's not), indexing a vector by codepoint (ie 32 bits) makes more sense from a processing POV.