UTF-8 maps all 1,112,064 valid Unicode code points into sequences of one to four 8-bit bytes while keeping every 7-bit ASCII character as a single unchanged byte [1][2]. Because code points U+0000 through U+007F match byte values 0x00 through 0x7F, any plain ASCII file is already valid UTF-8 without conversion [1][2]. By 2026, UTF-8 accounted for 99.1% of public web pages, and the Web Hypertext Application Technology Working Group (WHATWG) calls it “the mandatory encoding for all things.” [1][3]
From ASCII to Unicode
Early computers stored and exchanged English text using 7-bit ASCII, an encoding of 128 characters covering Latin letters, digits, punctuation, and control codes like tabs and newlines. Computing spread worldwide, so programmers needed a way to handle scripts such as Chinese, Japanese, Arabic, and Cyrillic in the same document [5][6].
In 1988, Joseph D. Becker published the first draft proposal for Unicode, assuming 16 bits per character would be enough, and Unicode 1.0 shipped in 1991 with 65,536 code points from U+0000 to U+FFFF [6][8]. Meanwhile, the International Organization for Standardization (ISO) started designing a universal multi-byte character set in 1989. Its draft ISO 10646 standard included an annex called UTF-1, which ran slowly and let multi-byte sequences reuse ASCII bytes such as 0x2F, breaking Unix path separators [1].
In July 1992, Dave Prosser of Unix System Laboratories proposed a faster scheme to the X/Open XoJIG committee that kept 7-bit ASCII values exclusive to ASCII characters. Two months later, on September 2, 1992, Ken Thompson and Rob Pike sketched a self-synchronizing variation on a placemat in a New Jersey diner. They built it into the Plan 9 operating system, X/Open adopted it as FSS-UTF, and developers presented it at USENIX in January 1993 [1]. Unicode 1.1 included FSS-UTF in Appendix F in 1993, and ISO 10646 and The Unicode Standard Version 2.0 formally approved UTF-8 in 1996 before F. Yergeau wrote RFC 3629 in 2003 [2][7].

How UTF-8 Encodes Code Points
UTF-8 encodes each Unicode scalar value as one to four 8-bit bytes, using fewer bytes for lower numerical code points [1]. Every sequence starts with a distinct leading bit pattern that tells a decoder exactly how many bytes belong to that character [2][5].
Single-byte characters from U+0000 to U+007F start with a 0 bit, leaving seven bits for standard ASCII values (0xxxxxxx). Multi-byte characters always set the high bit to 1: two-byte sequences start with 110, three-byte sequences start with 1110, and four-byte sequences start with 11110 [2][5]. Every byte after the first begins with the prefix 10, leaving six data bits (10xxxxxx) to hold bits from the character’s binary number [2][5].
Two bytes cover the next 1,920 code points (U+0080 to U+07FF), including Greek, Cyrillic, Armenian, Hebrew, Arabic, and extra Latin characters. Three bytes cover the remaining 61,440 code points of the Basic Multilingual Plane (U+0800 to U+FFFF), where most Chinese, Japanese, and Korean text lives. For example, the character 桁 (U+6841) splits its 16 bits across three bytes as 11100110 10100001 10000001. Four bytes handle all 1,048,576 supplementary characters from U+10000 to U+10FFFF [1][8]. Matt Galloway showed that the chicken emoji (U+1F414) fills 21 payload bits into 0xF0 0x9F 0x90 0x94 [5].
Self-Synchronizing Byte Streams
A UTF-8 reader can start at any byte offset in a file and find the next character boundary by checking high bits and backing up at most three bytes. That works because single-byte ASCII (0x00–0x7F), leading multi-byte prefixes (110, 1110, 11110), and continuation bytes (0x80–0xBF) never share bit patterns [1][2].
UTF-8 also operates as a prefix code, so a parser knows the exact length of a character from its first byte without scanning past its final byte. Older multi-byte encodings like Shift_JIS lack this separation and let trailing bytes match ASCII values [1]. In a 2011 security flaw reported by WHATWG, a Shift_JIS leading byte (0x82) swallowed a trailing 0x22 quote mark in JSON and broke the document structure [3].

Keeping ASCII bytes separate lets C functions such as printf() and file-system tools scan for null bytes or slashes without misreading non-ASCII text. The leading prefixes also preserve numerical order, so sorting UTF-8 strings by raw byte value produces the same result as sorting 32-bit UTF-32 code points—though F. Yergeau noted in RFC 3629 that code-point order rarely matches cultural sorting rules [2]. Fast string algorithms like Boyer-Moore search run directly on UTF-8 bytes, and because a random high-bit byte has only a 1-in-15 chance of starting a valid character, software can reliably spot UTF-8 without extra metadata [1][2].
Invalid Sequences and Security
Not every byte combination is legal in UTF-8: byte values 0xC0, 0xC1, and 0xF5 through 0xFF never occur in valid output [1][2]. Decoders must also catch truncated sequences, stray continuation bytes, and values exceeding U+10FFFF [1].
An overlong encoding happens when an encoder packs a small code point into more bytes than its range needs, such as writing U+003F as 0xC0 0xBF instead of 0x3F. Early decoders ignored the wasted leading bits, which let attackers hide ASCII slashes or ../ sequences past security checks in products such as Microsoft’s IIS server and Apache’s Tomcat container. RFC 3629 prohibits decoding any overlong sequence [1][2].
The Unicode Standard tells decoders to “neither interpret nor emit an ill-formed code unit sequence.” Early versions of Python 3.0 threw exceptions and exited if invalid UTF-8 appeared in environment variables or command-line arguments, turning minor encoding mismatches into crashes. Most decoders now substitute U+FFFD (“) and keep reading, and since Unicode 6 in October 2010, the standard recommends stopping an error run before any valid ASCII byte so E1 A0 20 keeps its trailing space [1][3]. Software can also encounter a three-byte Byte Order Mark (0xEF 0xBB 0xBF), which Unicode neither requires nor recommends; in 2018, BleepingComputer reported that Windows 10 Notepad Build 1903 switched its default save format to UTF-8 without a BOM [1][11].

UTF-8 vs. UTF-16
UTF-16 emerged in July 1996 with Unicode 2.0 (and RFC 2781 in 2000) after programmers saw that fixed-width 16-bit UCS-2 could not fit more than 65,536 characters [4][6]. Wikipedia’s UTF-16 entry states bluntly, “UCS-2 should now be considered obsolete.” [4]
UTF-16 encodes BMP characters in one 16-bit unit and supplementary characters in two 16-bit surrogate units [4][5]. Because 16-bit units split into two bytes on disk, UTF-16 needs two variants—big-endian (UTF-16BE) and little-endian (UTF-16LE)—whereas UTF-8 is byte-ordered by design and immune to endianness swaps [3][6]. Windows APIs, Java, and Qt still use UTF-16, yet fewer than 0.003% of public web pages declare it, and WHATWG forbids browsers from favoring it [4][6].
File size depends on script mix rather than a single rule [6]. UTF-8 stores English letters and HTML or XML tags in one byte per character, takes two bytes for Cyrillic, Hebrew, and Arabic (matching UTF-16), and uses three bytes for most CJK ideographs compared to two bytes in UTF-16 [1]. The UTF-8 Everywhere manifesto notes that Unicode spans over 109,449 characters—roughly 74,500 of them CJK ideographs—yet English markup around web text keeps UTF-8 compact [6]. Treating UTF-16 as fixed-width also caused bugs: plain Windows edit controls before Vista needed two backspaces to erase a four-byte character, and the Windows 7 console printed it as two broken glyphs [4][6].

Unpaired Surrogates in Practice
RFC 3629 outlawed encoding code points U+D800 through U+DFFF in UTF-8 because UTF-16 reserves that block exclusively for surrogate pairs [1][2]. That restriction removed over 3% of three-byte patterns and eliminated all five- and six-byte sequences above U+10FFFF [1].
However, systems that store text in 16-bit code units—such as Windows filenames (WCHAR), JavaScript strings, and Java—do not force every surrogate unit to come in a valid pair. Simon Sapin calls these strings “potentially ill-formed UTF-16,” or WTF-16. To preserve raw Windows paths without dropping bytes, Sapin specified WTF-8 (Wobbly Transformation Format – 8-bit) as a private superset of UTF-8. WTF-8 encodes unpaired surrogates in three bytes (0xED plus 0xA0–0xBF) while still encoding paired supplementary characters in four bytes, and it must never cross network boundaries or receive an IANA charset label [8].
Other variants address older system limits in different ways [2][9][10]. Compatibility Encoding Scheme for UTF-16: 8-Bit (CESU-8) turns each 16-bit surrogate into three bytes, bloating four-byte emoji to six bytes, while Java’s DataInput and DataOutput interfaces use a modified UTF-8 that encodes U+0000 (\u0000) as two bytes so strings never contain embedded null bytes [2][8][9]. Earlier still, RFC 1642 and RFC 2152 defined UTF-7 to carry Unicode through 7-bit e-mail gateways via modified Base64, but it lacked official Unicode status, suffered security flaws, and is banned in HTML 5 [10].
UTF-8 Support in Major Runtimes
Unix-like systems adopted narrow UTF-8 byte strings early, while Windows anchored its core APIs in UTF-16 (WCHAR) and regional ANSI code pages [6]. Cross-platform C and C++ code on Windows had to convert strings using MultiByteToWideChar and WideCharToMultiByte [12].
Recent platform updates have pushed Windows tools and language runtimes toward UTF-8 defaults [12][13][14]. Starting with Windows 10 Build 1903 (19H1), apps can declare an ActiveCodePage of UTF-8 in their manifest, and Microsoft’s Game Development Kit (GDK) uses UTF-8 as the sole ANSI code page on consoles [12]. In Python 3.6, Steve Dower’s PEP 529 switched the Windows filesystem encoding from mbcs to UTF-8 with surrogatepass over wide APIs [13]. Python 3.15, released on October 9, 2026, later made UTF-8 the language’s default encoding, and PyPy v7.1 moved its Unicode string storage to UTF-8 in March 2019 [14][15].

Ruby made a similar shift in Ruby 3.0 through Feature #12650 (UTF-8 for Windows environment variables) and Feature #16604 (changing Encoding.default_external from legacy OEM pages like cp850 to UTF-8, matching PowerShell 6.0 and 6.1) [16]. Spreadsheet tools still trip up users of Microsoft Excel when importing or exporting comma-separated files. Roland Dalmulder recommends saving CSVs as UTF-8 in LibreOffice or OpenOffice because Excel lacks an export encoding lock, while Microsoft Q&A advises Windows Excel users to choose 65001: Unicode (UTF-8) in the Text Import Wizard [17][18].
Validation and Text Compression
Every parser ingesting untrusted files or web streams must verify that incoming bytes follow UTF-8 rules before passing text along [3]. Checking byte ranges one character at a time can create a bottleneck on high-speed servers [19].
In 2020, J. Keiser and D. Lemire published a lookup-based validation method in Software: Practice and Experience that runs in less than one CPU instruction per byte. Their open-source algorithm relies on single-instruction-multiple-data (SIMD) vector instructions available on modern processors and outperformed validation routines in many standard libraries and languages by more than 10 times [19].
Compression tools also react differently to multi-byte UTF-8 sequences than to single-byte alphabets. In a 2015 study in the International Journal of Computer Science and Information Technology, W. J. Teahan and K. M. Alhawiti tested preprocessing tricks for Prediction by Partial Matching (PPM) compression on UTF-8 natural language text. Substituting two-byte bigraphs before compressing improved PPM ratios by 25% for Arabic, 14% for Armenian, 9% for Persian, 15% for Russian, 1% for Chinese, and over 5% for English and Welsh. Splitting text into separate vocabulary and symbol streams boosted PPM gains even further—reaching 24% for Arabic, 30% for Armenian, 32% for Persian, and 35% for Russian [20].
- WEBSITE Wikipedia. (n.d.). UTF-8. [Article Link]
- REPORT Yergeau, F. (2003). UTF-8, a transformation format of ISO 10646 (RFC 3629; STD 63). Internet Engineering Task Force. [Article Link]
- REPORT WHATWG. (2026). Encoding Living Standard. [Article Link]
- WEBSITE Wikipedia. (n.d.). UTF-16. [Article Link]
- WEBSITE Galloway, M. (2012). Character encoding for iOS developers. Or UTF-8 what now? [Article Link]
- WEBSITE UTF-8 Everywhere. (n.d.). UTF-8 Everywhere Manifesto. [Article Link]
- WEBSITE Whistler, K. (2001). FSS-UTF, UTF-2, UTF-8, and UTF-16. Unicode Mailing List Archive. [Article Link]
- WEBSITE Sapin, S. (2022). The WTF-8 encoding. [Article Link]
- WEBSITE Oracle. (2026). Interface DataInput (Java Platform SE 8). [Article Link]
- WEBSITE Wikipedia. (n.d.). UTF-7. [Article Link]
- ONLINE NEWS Abrams, L. (2018). Windows 10 Notepad is getting better UTF-8 encoding support. BleepingComputer. [Article Link]
- WEBSITE Microsoft Learn. (2025). UTF-8 support in the Microsoft Game Development Kit (GDK). [Article Link]
- REPORT Dower, S. (2016). PEP 529 – Change Windows filesystem encoding to UTF-8. Python Enhancement Proposals. [Article Link]
- WEBSITE Python Software Foundation. (2026). What’s new in Python 3.15. Python Documentation. [Article Link]
- WEBSITE PyPy Team. (2019). PyPy v7.1 released; now uses utf-8 internally for unicode strings. PyPy Status Blog. [Article Link]
- WEBSITE Ruby Issue Tracking System. (2020). Feature #16604: Set default for Encoding.default_external to UTF-8 on Windows. [Article Link]
- WEBSITE Dalmulder, R. (n.d.). Save a CSV file as UTF-8. RolandD. [Article Link]
- WEBSITE Microsoft Learn. (2020). How to open UTF-8 CSV file in Excel without mis-conversion of characters in Japanese and Chinese language for both Mac and Windows? Microsoft Q&A. [Article Link]
- ACADEMIC JOURNAL Keiser, J., & Lemire, D. (2020). Validating UTF-8 in less than one instruction per byte. Software: Practice and Experience, 51(5), 950–964. [Article Link]
- ACADEMIC JOURNAL Teahan, W. J., & Alhawiti, K. M. (2015). Preprocessing for PPM: Compressing UTF-8 encoded natural language text. International Journal of Computer Science and Information Technology, 7(2), 41–51. [Article Link]
Cover image: Callidus / Wikimedia Commons, CC BY-SA 3.0