Estimate the UTF-8 byte size from counts of ASCII and multibyte characters (CJK, emoji) for storage estimation.
用于估算多语言文本存储空间。
| Item | Formula / Rule | Source / Standard |
|---|---|---|
| Byte-length tiers | U+0000–U+007F uses 1 byte, U+0080–U+07FF uses 2, U+0800–U+FFFF uses 3, U+10000–U+10FFFF uses 4 | ISO/IEC 10646 / RFC 3629 §3 |
| Surrogate exclusion | U+D800–U+DFFF are UTF-16 surrogates and are invalid in UTF-8 | Unicode Standard §3.9, Table 3-7 |
| Self-synchronization | The count of leading 1 bits in the lead byte equals the total byte length | RFC 3629 §3, UTF-8 syntax |