UTF-16
UTF-16 is Unicode's variable-length encoding form, using 2 or 4 bytes per code point: BMP characters take one 16-bit code unit and supplementary-plane characters take a surrogate pair (2 code units).
Purpose
It balances space efficiency with full Unicode coverage where BMP characters dominate, such as the Windows API and Java's internal string representation.
Mechanism
A BMP code point (U+0000-FFFF) is stored directly as one 16-bit unit. A supplementary code point (U+10000-10FFFF) has 0x10000 subtracted, then splits into high and low 10-bit halves offset by 0xD800 and 0xDC00 to form a surrogate pair. Byte order is indicated by the BOM (U+FEFF).
Use cases
- Internal Windows API strings
- Internal Java/JavaScript string representation
- Internal .NET String storage
- File name (NTFS) storage
Examples
- Input
AOutput0x00 0x41UTF-16BE, 2 bytes
- Input
😀Output0xD8 0x3D 0xDE 0x00A surrogate pair, 4 bytes
Common errors
- Ignoring surrogate pairs, producing wrong character counts
- Use code-point-aware APIs or surrogate-pair-aware iteration
Related terms
Unicode
Unicode is the international character encoding standard that assigns a unique code point (U+0000 through U+10FFFF) to every character of nearly all the world's writing systems, with a codespace of 1,114,112 code points. GLOSSARY
UTF-8
UTF-8 is Unicode's variable-length encoding form, using 1 to 4 bytes per code point; it is fully backward compatible with ASCII and is the de facto standard for the web and modern systems. GLOSSARY
Surrogate Pair
A surrogate pair is the UTF-16 mechanism that represents one supplementary-plane code point (U+10000 through U+10FFFF) using two 16-bit code units. GLOSSARY
BOM
The BOM (byte order mark) is the Unicode character U+FEFF, placed at the start of a text stream to indicate the encoding form and byte order. GLOSSARY
Endianness
Endianness is the byte ordering of multi-byte values in memory: big-endian stores the most significant byte first, little-endian the least significant byte first. GLOSSARY
Related tools
Unicode Converter
Convert text to Unicode code points, UTF-8 hex, or UTF-16 hex online. Free, private, and 100% client-side. TOOL
Charset Reference
Reference table of character encodings. Free, private, 100% client-side. TOOL
Utf8 To Utf16
Utf8 To Utf16 — pure client-side tool. Privacy-first, no server round-trip. TOOL