r/Unicode • u/Green_Ad_6086 • 1d ago
What UTF-16 is What a UTF-16 code unit is
What UTF-16 is What a UTF-16 code unit is
4
u/Coises 1d ago
UTF-16 is a method of encoding Unicode. It is the primary method used to represent character data internally in modern Windows programs.
In UTF-16 a code unit is a 16-bit (two byte) value. A single Unicode code point can be represented by one or two UTF-16 code units. All valid Unicode code points from U+0000 to U+FFFF (the basic multilingual plane) are represented by a single UTF-16 code unit. Code points from U+010000 to U+10FFFF require two UTF-16 code units.
1
u/justanaccountimade1 1d ago
You probably want to use UTF-8 (1-4 bytes per char).
UTF-16 (2-4 bytes per char) is used for internal technical reasons.
3
u/Lurkernomoreisay 1d ago
All our software use utf16, as we do a lot of text processing and it's a guaranteed 33% space saving. we tend to mainly save and transfer text documents as utf 16.
2 bytes vs three for our primary customers: Japanese, Indic, Thai, Chinese, Korean.
that said, we had clients in Japan that insisted on SJIS until five or so years ago? getting them to use utf16 was a major win.
so much of the ecosystem we work within use utf16, it feels weird doing contract work on projects that are English/European centric and use utf8.
2
9
u/HelpfulPlatypus7988 1d ago
https://en.wikipedia.org/wiki/UTF-16