Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
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.