4 ms·
> Also it says "strlen("有り難う")); [...] and the output is… The length of the string is 12 characters". But according to "man strlen": "RETURN VALUE: The strlen()
by nordsieck 4y ago
> Also it says "strlen("有り難う")); [...] and the output is… The length of the string is 12 characters". But according to "man strlen": "RETURN VALUE: The strlen() function returns the number of bytes in the string pointed to by s.". It says nothing about "number of characters".
Yeah - when dealing with Unicode, you have to be very clear about whether you're dealing with bytes, runes or glyphs.
- riceart 4y agoRunes are not a Unicode concept - that’s a Golangism. Basically a code point. Also in terms of Unicode, graphemes are even more relevant to the programming side than glyphs - unless you’re writing a renderer.