Assuming Char Represents One Character

Do not assume char represents only one character:

"uD83DuDC31".length() == 2

The escape sequence represents the Unicode code point 0x1F431 in UTF-16 as 2 chars. So even though this is only a single cat face symbol on the screen, the length() method returns 2.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: