Comment

Comment by pygy_

A good summary, but for one imortant detail: In UTF-16, some code points (laying on the so-called "astral planes", ie not on the "basic multilingual plane") take 32 bits.

The Emoji, for example, lie on the first higher plane: πŸ’πŸŽ„πŸ°πŸš΄. Firefox and Safari display them properly, Chrome doesn't, no idea for IE and Opera.

UCS-2 is a strict 16-bit encoding (a subset of UTF-16), and it cannot represent all characters.

It is the encoding used by JavaScript, which can be problematic when double width characters are used. For example, `"πŸ™πŸšπŸ›πŸœπŸπŸžπŸŸ".length` is 14 even though there are only seven characters, and you could slice that string in the middle of a character.

parent pygy_ 13 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News Β· SvelteKit + Skeleton