This is potentially dangerous, as it encourages dealing with text as an array of chars. But graphemes in Unicode, which represent a single symbol in a writing system (such as “H”, “心”, or “💚”), can take up multiple chars in a string. The linked approaches only work if you can guarantee that your string only contains ASCII. See also: The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!)
This is potentially dangerous, as it encourages dealing with text as an array of
char
s. But graphemes in Unicode, which represent a single symbol in a writing system (such as “H”, “心”, or “💚”), can take up multiplechar
s in a string. The linked approaches only work if you can guarantee that your string only contains ASCII. See also: The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!)Yes, good point - I’d forgotten about Unicode in this context.