Re:Unicode nearing 50% of the web
by gchpaco on Thursday January 28, 2010 @04:56PM
(#1085153)
But UTF-16 is far more advantageous an encoding if you speak Chinese, Arabic, Russian, or Japanese; UTF-8 can take up to four bytes per character for some of those.
[ Parent
| on HN ]
The interesting character ranges are:
U+0000 to U+007F: 1 byte for UTF-8, 2 for UTF-16
U+0080 to U+07FF: 2 bytes for UTF-8 and UTF-16
U+0800 to U+FFFF: 3 bytes for UTF-8, 2 for UTF-16
U+10000 and up: 4 bytes for UTF-8 and UTF-16
Arabic, Cyrillic (Russian), Tamil, Thai, Hebrew, and many other non-European scripts take an equal amount of space in either UTF-8 and UTF-16. Japanese and Korean have some cases where UTF-16 is more efficient, but only by a byte, and most Chinese characters take 4 bytes either way.Additionally, since we're talking about web pages, the markup tags will still be composed of ASCII characters, for which UTF-8 has an advantage.
In a world where I can load my cell phone up with 4GB of flash for ~$10, I don't think anybody really cares.
For network transmission, even gzip compression will take the sting out.
Oh, I know it's not free. I'm not saying it's free. I'm just saying it's nowhere near the pain point for most people. The days of using a computer and fearing that you might type a report for school so long the machine will run out of memory are long gone.
So?
UTF-16 is a lot more work to support. For example, do I store the BOM in every string when I store a name in a database?
It's harder to handle UTF-16 because of all the nulls.
And since Chinese stores an entire word in a single character, I'm perfectly fine with their words taking 4 bytes. An average word in English uses 5 letters.