UTF-16
UTF-16 (16-bit Unicode Transformation Format) is a character encoding that supports all 1,112,064 valid code points of Unicode. The encoding is variable-length as code points are encoded with one or two code units. UTF-16 arose from an earlier obsolete fixed-width 16-bit encoding now known as UCS-2 (for 2-byte Universal Character Set), once it became clear that more than 2 16 (65,536) code points were needed, including most emoji and important CJK characters such as for personal and place names. UTF-16 is used by the Windows API, and by many programming environments such as Java and Qt. The variable-length character of UTF-16, combined with the fact that most characters are not variable-length (so variable length is rarely tested), has led to many bugs in software, including in Windows itself. UTF-16 is the only encoding (still) allowed on the web that is incompatible with 8-bit ASCII. It has never gained popularity on the web, where it is declared by under 0.003% of public web...
UTF-16 (16-bit Unicode Transformation Format) is a character encoding that supports all 1,112,064 valid code points of Unicode. The encoding is variable-length as code points are encoded with one or two code units. UTF-16 arose from an earlier obsolete fixed-width 16-bit encoding now known as UCS-2 (for 2-byte Universal Character Set), once it became clear that more than 2 16 (65,536) code points were needed, including most emoji and important CJK characters such as for personal and place names. UTF-16 is used by the Windows API, and by many programming environments such as Java and Qt. The variable-length character of UTF-16, combined with the fact that most characters are not variable-length (so variable length is rarely tested), has led to many bugs in software, including in Windows itself. UTF-16 is the only encoding (still) allowed on the web that is incompatible with 8-bit ASCII. It has never gained popularity on the web, where it is declared by under 0.003% of public web pages (and even then, the web pages are most likely also using UTF-8 ). UTF-8, by comparison, gained dominance years ago and accounted for 99.1% of all web pages by 2026. The Web Hypertext Application Technology Working Group (WHATWG) considers UTF-8 "the mandatory encoding for all [text]" and that for security reasons browser applications should not use UTF-16. 16.0.01 Plane 0 map. The white stripe near the bottom is the surrogate code point range. Illustrated visually, the distribution of U between W1 and W2 looks like: U' = yyyyyyyyyyxxxxxxxxxx // U - 0x10000 W1 = 110110yyyyyyyyyy // 0xD800 + yyyyyyyyyy W2 = 110111xxxxxxxxxx // 0xDC00 + xxxxxxxxxx Since the ranges for the high surrogates ( ), low surrogates ( ), and valid BMP characters (0x0000–0xD7FF, 0xE000–0xFFFF) are disjoint, it is not possible for a surrogate to match a BMP character, or for two adjacent code units to look like a legal surrogate pair. This simplifies searches a great deal. It also means that UTF-16 is self-synchronizing on 16-bit words: whether a code unit starts a character can be determined without examining earlier code units (i.e. the type of code unit can be determined by the ranges of values in which it falls). UTF-8 shares these advantages, but many earlier multi-byte encoding schemes (such as Shift JIS and other Asian multi-byte encodings) did not allow unambiguous searching and could only be synchronized by re-parsing from the start of the string. UTF-16 is not self-synchronizing if one byte is lost or if traversal starts at a random byte. Because the most commonly used characters are all in the BMP, handling of surrogate pairs is often not thoroughly tested. This leads to persistent bugs and potential security holes, even in popular and well-reviewed application software (e.g. ). For the high surrogate, shift right by 10 (divide by 0x400), then add 0xD800, resulting in 0x0001 + 0xD800 = 0xD801. For the low surrogate, take the low 10 bits (remainder of dividing by 0x400), then add 0xDC00, resulting in 0x0037 + 0xDC00 = 0xDC37. To decode U+10437 (𐐷) from UTF-16: Take the high surrogate (0xD801) and subtract 0xD800, then multiply by 0x400, resulting in 0x0001 × 0x400 = 0x0400. Take the low surrogate (0xDC37) and subtract 0xDC00, resulting in 0x37. Add these two results together (0x0437), and finally add 0x10000 to get the final code point, 0x10437. The following table summarizes this conversion, as well as others. The colors indicate how bits from the code point are distributed among the UTF-16 bytes. Additional bits added by the UTF-16 encoding process are shown in black.
References
- ^ This number is in fact a consequence of UTF-16. There are 2 16 − 2048 + 1024 · 1024 = 1,112,064 code points that can be encoded by UTF-16. Unicode was restricted to these code points when UTF-16 was added to the standard. Before that Unicode had 2 31 = 2,147,483,648 valid code points. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ UTF-32 is also incompatible with ASCII, but is not listed as a web-encoding. [ 8 ] Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "Usage Statistics and Market Share of UTF-16 for Websites, November 2025" . w3techs.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "Usage Statistics and Market Share of UTF-8 for Websites, September 2026" . w3techs.com . Retrieved 2026-09-10 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1788994800.0
- ^ "MySQL :: MySQL 5.7 Reference Manual :: 10.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding)" . dev.mysql.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "FAQ - UTF-8, UTF-16, UTF-32 & BOM" . www.unicode.org . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ ISO/IEC 10646:2014 "Information technology – Universal Coded Character Set (UCS)" sections 9 and 10. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "Chapter 2 General Structure" (PDF) . The Unicode Standard version 7.0 . 2014. 2.5 Encoding Forms. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "Character Encoding Stability" . unicode.org . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "Conformance" . The Unicode Standard (6.0 ed.). Mountain View, California, US: The Unicode Consortium . 3.9 Unicode Encoding Forms. ISBN 978-1-936213-01-6 . Each encoding form maps the Unicode code points U+0000..U+D7FF and U+E000..U+10FFFF Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ Yergeau, Francois; Hoffman, Paul (February 2000). "UTF-16, an encoding of ISO 10646" . tools.ietf.org . Retrieved 2019-06-18 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1560812400.0
- ^ The Unicode Consortium (2025). "The Unicode® Standard ; Version 17.0 – Core Specification ; 3.8 Surrogates" . South San Francisco . Retrieved 2026-08-28 . Isolated surrogate code units have no interpretation on their own. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1787871600.0
- ^ The Unicode Consortium (2025). "The Unicode® Standard ; Version 17.0 – Core Specification ; 3.9.2 UTF-16" . South San Francisco . Retrieved 2026-08-28 . Because surrogate code points are not Unicode scalar values, isolated UTF-16 code units in the range D800₁₆..DFFF₁₆ are ill-formed. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1787871600.0
- ^ "Maximum Path Length Limitation" . Microsoft . 2022-07-18 . Retrieved 2022-10-10 . […] the file system treats path and file names as an opaque sequence of WCHARs Wikipedia revision 1374582435, retrieved 2026-11-19 · 1665356400.0
- ^ "Unicode UTF-16 Surrogate Pairs Example" . ClarionHub . 2026-01-18 . Retrieved 2026-07-03 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1783033200.0
- ^ UTF-8 encoding produces byte values strictly less than 0xFE, so either byte in the BOM sequence also identifies the encoding as UTF-16 (assuming that UTF-32 is not expected). Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ Use of U+FEFF as the character ZWNBSP instead of as a BOM has been deprecated in favor of U+2060 (WORD JOINER); see Byte Order Mark (BOM) FAQ at Unicode.org. But if an application interprets an initial BOM as a character, the ZWNBSP character is invisible, so the impact is minimal. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ RFC 2781 section 4.3 says that if there is no BOM, "the text SHOULD be interpreted as being big-endian." According to section 1.2, the meaning of the term "SHOULD" is governed by RFC 2119 . In that document, section 3 says "... there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course". Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "It's not wrong that "🤦🏼♂️".length == 7" . hsivonen.fi . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "Unicode" . Microsoft Learn . Retrieved 2011-03-08 . These functions use UTF-16 (wide character) encoding (…) used for native Unicode encoding on Windows operating systems. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1299538800.0
- ^ Archiveddocs. "Working With Unicode Surrogates (Windows CE 5.0)" . learn.microsoft.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "Surrogates and Supplementary Characters" . Microsoft Learn . 2022-05-24. Windows 2000 introduces support for basic input, output, and simple sorting of supplementary characters. However, not all system components are compatible with supplementary characters. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ Karl-Bridge-Microsoft. "Unicode - Win32 apps" . learn.microsoft.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ Karl-Bridge-Microsoft. "Surrogates and Supplementary Characters - Win32 apps" . learn.microsoft.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "UCS-2 and its relationship to Unicode (UTF-16)" . www.ibm.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ Karl-Bridge-Microsoft. "Character Sets Used in File Names - Win32 apps" . learn.microsoft.com . Retrieved 2025-10-11 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1760137200.0
- ^ Chad Selph (2012-11-08). "Adventures in Unicode SMS" . Twilio. Archived from the original on 2015-09-08 . Retrieved 2015-08-28 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1440716400.0
- ^ "PEP 393 – Flexible String Representation | peps.python.org" . Python Enhancement Proposals (PEPs) . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "PEP 623 – Remove wstr from Unicode | peps.python.org" . Python Enhancement Proposals (PEPs) . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "JDK 9 Release Notes - New Features" . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "Java Development Kit Version 24 API Specification" . docs.oracle.com . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ "Java SE documentation for Interface java.io.DataInput, subsection on Modified UTF-8" . Oracle Corporation . 2015 . Retrieved 2015-10-16 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1444950000.0
- ^ "JavaScript's internal character encoding: UCS-2 or UTF-16? · Mathias Bynens" . mathiasbynens.be . Retrieved 2025-11-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1763593200.0
- ^ BillWagner. "UTF-8 string literals - C# feature specifications" . learn.microsoft.com . Retrieved 2026-03-22 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1774134000.0
- ^ "Utf8Parser Class (System.Buffers.Text)" . learn.microsoft.com . Retrieved 16 April 2026 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "UTF-8 String" . Swift.org . 2019-03-20 . Retrieved 2020-08-20 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1597878000.0
- ^ "PHP: Supported Character Encodings - Manual" . php.net . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "MySQL :: MySQL 8.0 Reference Manual :: 10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)" . dev.mysql.com . Retrieved 2023-02-24 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1677193200.0
- ^ "HTML Living Standard" . w3.org . 2020-06-10. Archived from the original on 2020-09-08 . Retrieved 2020-06-15 . UTF-16 encodings are the only encodings that this specification needs to treat as not being ASCII-compatible encodings. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1592175600.0
- ^ "Encoding Standard" . encoding.spec.whatwg.org . Retrieved 2023-04-22 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1682118000.0
- ^ "Use UTF-8 code pages in Windows apps" . learn.microsoft.com . Retrieved 2020-06-06 . As of Windows version 1903 (May 2019 update), you can use the ActiveCodePage property in the appxmanifest for packaged apps, or the fusion manifest for unpackaged apps, to force a process to use UTF-8 as the process code page. [...] CP_ACP equates to CP_UTF8 only if running on Windows version 1903 (May 2019 update) or above and the ActiveCodePage property described above is set to UTF-8. Otherwise, it honors the legacy system code page. We recommend using CP_UTF8 explicitly. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1591398000.0
- ^ "UTF-8 support in the Microsoft Game Development Kit (GDK) - Microsoft Game Development Kit" . learn.microsoft.com . Retrieved 2023-03-05 . By operating in UTF-8, you can ensure maximum compatibility [..] Windows operates natively in UTF-16 (or WCHAR), which requires code page conversions by using MultiByteToWideChar and WideCharToMultiByte. This is a unique burden that Windows places on code that targets multiple platforms. [..] The Microsoft Game Development Kit (GDK) and Windows in general are moving forward to support UTF-8 to remove this unique burden of Windows on code targeting or interchanging with multiple platforms and the web. Also, this results in fewer internationalization issues in apps and games and reduces the test matrix that's required to get it right. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1677970800.0
- ^ "What is UTF-16?" . The Unicode Consortium . Unicode, Inc . Retrieved 7 January 2023 . UTF-16 uses a single 16-bit code unit to encode over 60,000 of the most common characters in Unicode Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ Allen, Julie D.; Anderson, Deborah; Becker, Joe ; Cook, Richard, eds. (2014). "3.8 Surrogates" (PDF) . The Unicode Standard, Version 7.0—Core Specification . Mountain View: The Unicode Consortium . p. 118. Archived (PDF) from the original on 2022-10-09 . Retrieved 3 November 2014 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "Should UTF-16 be considered harmful?" . Software Engineering Stack Exchange . Retrieved 2024-11-20 . File names editing in Window dialogs in broken (delete required 2 presses on backspace) Wikipedia revision 1374582435, retrieved 2026-11-19 · 1732057200.0
- ^ "Encoding Standard" . encoding.spec.whatwg.org . Retrieved 2018-10-22 . The UTF-8 encoding is the most appropriate encoding for interchange of Unicode, the universal coded character set. Therefore for new protocols and formats, as well as existing formats deployed in new contexts, this specification requires (and defines) the UTF-8 encoding. [..] The problems outlined here go away when exclusively using UTF-8, which is one of the many reasons that UTF-8 is now the mandatory encoding for all text things on the Web. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1540162800.0
- ^ Lunde, Ken (2022-01-09). "2022 Top Ten List: Why Support Beyond-BMP Code Points?" . Medium . Retrieved 2024-01-07 . I first came up with the idea for this Top Ten List over 10 years ago, which was prompted by some environments that still supported only BMP code points. The idea, of course, was to motivate the developers of such environments to support code points beyond the BMP by providing an enumerated list of reasons to do so. And yes, there are still some environments that support only BMP code points, such as the VivaDesigner app. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1704582000.0
- ^ a b c "FAQ: What is the difference between UCS-2 and UTF-16?" . unicode.org . Archived from the original on 2003-08-18 . Retrieved 2024-03-19 . UCS-2 is obsolete terminology which refers to a Unicode implementation up to Unicode 1.1 [...] Wikipedia revision 1374582435, retrieved 2026-11-19 · 1710802800.0
- ^ a b c "C.2 Encoding Forms in ISO/IEC 10646" (PDF) . The Unicode Standard, version 6.0 . Mountain View, CA: Unicode Consortium . February 2011. p. 573. ISBN 978-1-936213-01-6 . [...] the term UCS-2 should now be considered obsolete. It no longer refers to an encoding form in either 10646 or the Unicode Standard. Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
- ^ "What is UTF-16?" . The Unicode Consortium . Unicode, Inc . Retrieved 29 March 2018 . Wikipedia revision 1374582435, retrieved 2026-11-19 · 1795042800.0
Cite this
"UTF-16". 1789246759. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1374582435