心律不齐是什么症状| 怀孕初期怕冷是什么原因| 奥美拉唑和雷贝拉唑有什么区别| 蛇肉吃了有什么好处| 中医的望闻问切是什么意思| 轴位什么意思| 什么时候取环最合适| 接触隔离什么意思| 袋鼠喜欢吃什么食物| 什么时候打仗| 吃什么能化解肾结石| 口周读什么| grace什么意思中文| 痛经吃什么食物| 49是什么意思| 什么野菜| Cr是什么意思医学| 为什么四川总地震| 冬季吃什么| 梅花在什么季节开放| 梦见猪下崽预兆什么| 五经指什么| 生理期提前是什么原因| 普洱在云南什么位置| 血糖高看什么科室| 小暑吃什么食物| 缺黄体酮会有什么症状| 嘴唇干是什么原因引起的| o型血可以接受什么血型| 怀孕初期吃什么食物好| 灏字五行属什么| 解体是什么意思| 女性手麻是什么原因| 增强抵抗力免疫力吃什么| 足字旁的字跟什么有关| 嘴唇颜色深是什么原因| 前是什么偏旁| 备孕需要做什么准备| 尿出血是什么原因| ntl是什么意思| 此起彼落是什么意思| 打包是什么意思| 血清和血浆有什么区别| 茯苓的功效与作用是什么| 啸是什么生肖| 被蜜蜂蛰了有什么好处| 经期吃什么食物比较好| 纸老虎是什么意思| 隆科多为什么不姓佟| 炒锅买什么材质的好| 脚痒用什么药| 奇异果和猕猴桃有什么区别| 乳腺结节有什么症状| 刘邦是什么生肖| 皮质醇是什么意思| 延年益寿的益是什么意思| 市政协主席是什么级别| 头发发黄是什么原因| ojbk什么意思| 带状疱疹挂什么科| 肾衰竭吃什么好| 阿托品属于什么类药物| 姬松茸和什么煲汤最佳| 卵巢多囊是什么原因造成的| 燊字五行属什么| 淋巴结有什么症状| 胆囊萎缩是什么原因| 梦见已故长辈什么预兆| 年底是什么时候| 跖疣念什么字| 左眼皮一直跳是什么预兆| 老年痴呆症是什么原因引起的| 痛风不能吃什么蔬菜| 宜余事勿取是什么意思| 81什么意思| 20点是什么时辰| 巴特尔是什么意思| 疑心病是什么意思| 一九三五年属什么生肖| 始终如一是什么意思| 孝庄是康熙的什么人| 早晨起床手麻是什么原因| 男人鼻头有痣代表什么| edifier是什么牌子| 阴囊潮湿吃什么中成药| 口腔溃疡白色的是什么| 田园生活是什么意思| beginning什么意思| 鸡眼用什么药好| dl是什么| 双肺纹理增粗是什么意思| 什么样的女人容易出轨| 喝完酒头疼是什么原因| 核磁共振主要检查什么| 三次元是什么| 岩茶属于什么茶| 撒贝宁是什么民族| 梦到屎是什么意思| 包皮垢是什么| 王八羔子是什么意思| 丙烯颜料用什么洗掉| 健康四大基石是什么| 一什么红枣| 阴道感染用什么药| 助听器什么品牌最好| 指甲发紫是什么原因| 奥美拉唑什么时候吃| 10月4号什么星座| 东方明珠什么时候亮灯| 双鱼座什么性格| 心律不齐是什么原因引起的| 挂读是什么意思| 千里莺啼什么映什么| 充电宝什么牌子好| 南非叶主治什么病| 偏心是什么意思| 二审是什么意思| o是什么牌子| 血小板低是什么病| 血小板偏低有什么危害| 活性炭和木炭有什么区别| 什么是溶血性疾病| 糖耐是检查什么| 范思哲香水是什么档次| 吃什么增强性功能| 心绞痛是什么病| 胎芽是什么| 眼睛散光是什么症状| 阿奇霉素主治什么病| 勿忘我是什么意思| 三铵复合肥是什么| 月经期间吃什么最好| 发挥是什么意思| 七月二十四是什么星座| vte是什么| 2009年什么年| 灵性是什么意思| 女人脾虚吃什么最好| 什么什么大叫| 母亲节一般送什么礼物| 假冒警察什么罪怎么判| 脑梗吃什么食物好| 三高挂号挂什么科| 怀孕初期能吃什么不能吃什么| 甲功五项查的是什么| 腿脚发麻是什么原因| 泳帽的作用是什么| 甲氧氯普胺片又叫什么| 什么哈欠| 乙肝五项245阳性是什么意思| 徐州二院全名叫什么| 做肉丸用什么淀粉最佳| 扭转乾坤是什么意思| 长期失眠吃什么食物好| 不应期是什么意思| 马来西亚信仰什么教| 独行侠是什么意思| 猪身上红疙瘩用什么药| 猪肝和什么菜搭配吃好| kids是什么品牌| 豆五行属什么| 法脉是什么意思| 泥鳅吃什么| 睡觉手麻是什么原因| 心脏早搏吃什么药效果好| 汽车拉缸有什么现象| 上眼皮有痣代表什么| burberry是什么品牌| 牙疼吃什么药消炎最快| 来姨妈喝什么比较好| 食道肿瘤有什么症状| 为什么卧室要用木地板| 9价疫苗适合什么年龄人打| 入幕之宾是什么意思| 不孕不育做什么检查| 玉米是什么植物| 清静是什么意思| 胃炎吃什么食物好养胃| 痰湿吃什么药| 胸骨突出是什么原因| 头发少剪什么发型好看| 杨梅什么时候成熟| 弱视和近视有什么区别| 舌头白吃什么药| 藩台是什么官| 男人梦见老鼠什么征兆| 宫寒是什么| 猫怕什么动物| 煮方便面什么时候放鸡蛋| 经常放屁是什么病| 67什么意思| 扑朔迷离什么意思| 知我者莫若你什么意思| 喝蜂蜜水对身体有什么好处| 男性支原体阳性有什么症状| 牙齿过敏吃什么药| 什么飞扬| 补血吃什么好| 防冻液红色和绿色有什么区别| 小孩儿咳嗽有什么妙招| 尿拉不出来是什么原因| 1995是什么年| 鬼是什么意思| 吃什么提高记忆力| 性冷淡是什么意思| 唯字五行属什么| 拉屎酸臭是什么原因| 老打瞌睡犯困是什么原因| 中国的八大菜系是什么| 灵魂伴侣是什么意思| 放生乌龟有什么寓意| 脑彩超能检查出什么| 璋字五行属什么| 小腿肚子疼是什么原因| 什么叫上门女婿| 23年属什么生肖| 怀孕时间从什么时候开始算| 查肝肾功能挂什么科| 尾巴翘上天是什么意思| gr是什么| 炒房是什么意思| 身上红痣多是什么原因| 身份证号码的数字代表什么意义| 美莎片是什么药| yet什么意思| 全身酸痛是什么原因| 维酶素片搭配什么药治萎缩性胃炎| 神经性呕吐是什么症状| 糖精是什么| 市检察长是什么级别| 什么是鳞状细胞| 甲沟炎是什么症状| 821是什么意思| 吃什么东西对眼睛好| 外翻是什么意思| 3月31日是什么星座| 头顶长白头发是什么原因造成的| 肝内结节是什么意思啊| 薄荷音是什么意思| 什么水解渴| 九牧王男装是什么档次| 副乳是什么| 1993年出生的属什么| opo是什么| 耳朵烫是什么原因| 汪星人什么意思| 2007年是什么命| 脾胃虚寒吃什么| 2021什么年| 一把手是什么意思| 茶叶水洗脸有什么好处| 金丝皇菊有什么功效| 鳄鱼的天敌是什么动物| 女人小腹痛什么原因| 什么的阳光| 胃疼是什么原因| 一百万存款算什么水平| 28岁属相是什么生肖| 肚子两侧疼是什么原因| 三是什么意思| 吃什么对胃好养胃的食物| 吃了避孕药后几天出血是什么原因| 康熙雍正乾隆是什么关系| 血脂是什么意思| 百度Jump to content

煎牛排用什么锅最好

From Wikipedia, the free encyclopedia
UTF-8
StandardUnicode Standard
ClassificationUnicode Transformation Format, extended ASCII, variable-length encoding
ExtendsASCII
Transforms / EncodesISO/IEC 10646 (Unicode)
Preceded byUTF-1
百度   赋予监察委员会宪法地位的意义着实重大,因为这是中国特色反腐败的全新理念和制度设计。

UTF-8 is a character encoding standard used for electronic communication. Defined by the Unicode Standard, the name is derived from Unicode Transformation Format – 8-bit.[1] As of July 2025, almost every webpage is transmitted as UTF-8.[2]

UTF-8 supports all 1,112,064[3] valid Unicode code points using a variable-width encoding of one to four one-byte (8-bit) code units.

Code points with lower numerical values, which tend to occur more frequently, are encoded using fewer bytes. It was designed for backward compatibility with ASCII: the first 128 characters of Unicode, which correspond one-to-one with ASCII, are encoded using a single byte with the same binary value as ASCII, so that a UTF-8-encoded file using only those characters is identical to an ASCII file. Most software designed for any extended ASCII can read and write UTF-8, and this results in fewer internationalization issues than any alternative text encoding.[4][5]

UTF-8 is dominant for all countries/languages on the internet, with 99% global average use, is used in most standards, often the only allowed encoding, and is supported by all modern operating systems and programming languages.

History

[edit]

The International Organization for Standardization (ISO) set out to compose a universal multi-byte character set in 1989. The draft ISO 10646 standard contained a non-required annex called UTF-1 that provided a byte stream encoding of its 32-bit code points. This encoding was not satisfactory on performance grounds, among other problems, and the biggest problem was probably that it did not have a clear separation between ASCII and non-ASCII: new UTF-1 tools would be backward compatible with ASCII-encoded text, but UTF-1-encoded text could confuse existing code expecting ASCII (or extended ASCII), because it could contain continuation bytes in the range 0x210x7E that meant something else in ASCII, e.g., 0x2F for /, the Unix path directory separator.

In July 1992, the X/Open committee XoJIG was looking for a better encoding. Dave Prosser of Unix System Laboratories submitted a proposal for one that had faster implementation characteristics and introduced the improvement that 7-bit ASCII characters would only represent themselves; multi-byte sequences would only include bytes with the high bit set. The name File System Safe UCS Transformation Format (FSS-UTF)[6] and most of the text of this proposal were later preserved in the final specification.[7][8][9] In August 1992, this proposal was circulated by an IBM X/Open representative to interested parties. A modification by Ken Thompson of the Plan 9 operating system group at Bell Labs made it self-synchronizing, letting a reader start anywhere and immediately detect character boundaries, at the cost of being somewhat less bit-efficient than the previous proposal. It also abandoned the use of biases that prevented overlong encodings.[9][10] Thompson's design was outlined on September 2, 1992, on a placemat in a New Jersey diner with Rob Pike. In the following days, Pike and Thompson implemented it and updated Plan 9 to use it throughout,[11] and then communicated their success back to X/Open, which accepted it as the specification for FSS-UTF.[9]

UTF-8 was first officially presented at the USENIX conference in San Diego, from January 25 to 29, 1993.[12] The Internet Engineering Task Force adopted UTF-8 in its Policy on Character Sets and Languages in RFC 2277 (BCP 18) for future internet standards work in January 1998, replacing Single Byte Character Sets such as Latin-1 in older RFCs.[13]

In November 2003, UTF-8 was restricted by RFC 3629 to match the constraints of the UTF-16 character encoding: explicitly prohibiting code points corresponding to the high and low surrogate characters removed more than 3% of the three-byte sequences, and ending at U+10FFFF removed more than 48% of the four-byte sequences and all five- and six-byte sequences.[14]

Description

[edit]

UTF-8 encodes code points in one to four bytes, depending on the value of the code point. In the following table, the characters u to z are replaced by the bits of the code point, from the positions U+uvwxyz:

Code point ? UTF-8 conversion
First code point Last code point Byte 1 Byte 2 Byte 3 Byte 4
U+0000 U+007F 0yyyzzzz
U+0080 U+07FF 110xxxyy 10yyzzzz
U+0800 U+FFFF 1110wwww 10xxxxyy 10yyzzzz
U+010000 U+10FFFF 11110uvv 10vvwwww 10xxxxyy 10yyzzzz

The first 128 code points (ASCII) need 1 byte. The next 1,920 code points need two bytes to encode, which covers the remainder of almost all Latin-script alphabets, and also IPA extensions, Greek, Cyrillic, Coptic, Armenian, Hebrew, Arabic, Syriac, Thaana and N'Ko alphabets, as well as Combining Diacritical Marks. Three bytes are needed for the remaining 61,440 codepoints of the Basic Multilingual Plane (BMP), including most Chinese, Japanese and Korean characters. Four bytes are needed for the 1,048,576 non-BMP code points, which include emoji, less common CJK characters, and other useful characters.[15]

UTF-8 is a prefix code and it is unnecessary to read past the last byte of a code point to decode it. Unlike many earlier multi-byte text encodings such as Shift-JIS, it is self-synchronizing so searches for short strings or characters are possible; and the start of a code point can be found from a random position by backing up at most 3 bytes. The values chosen for the lead bytes means sorting a list of UTF-8 strings puts them in the same order as sorting UTF-32 strings.

Overlong encodings

[edit]

Using a row in the above table to encode a code point less than "First code point" (thus using more bytes than necessary) is termed an overlong encoding. These are a security problem because they allow character sequences such as malicious JavaScript and ../ to bypass security validations, which has been reported in numerous high-profile products such as Microsoft's IIS web server[16] and Apache's Tomcat servlet container.[17] Overlong encodings should therefore be considered an error and never decoded. Modified UTF-8 allows an overlong encoding of U+0000.

Byte map

[edit]

The chart below gives the detailed meaning of each byte in a stream encoded in UTF-8.

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
2 ? ! " # $ % & ' ( ) * + , - . /
3 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4 @ A B C D E F G H I J K L M N O
5 P Q R S T U V W X Y Z [ \ ] ^ _
6 ` a b c d e f g h i j k l m n o
7 p q r s t u v w x y z { | } ~ ?
8
9
A
B
C 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
D 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
E 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
F 4 4 4 4 4 4 4 4 5 5 5 5 6 6
ASCII control character
ASCII character
Continuation byte
First byte of a 2-byte code unit sequence
First byte of a 3-byte code unit sequence
First byte of a 4-byte code unit sequence
Unused

Error handling

[edit]

Not all sequences of bytes are valid UTF-8. A UTF-8 decoder should be prepared for:

  • Bytes that never appear in UTF-8: 0xC0, 0xC1, 0xF50xFF
  • A "continuation byte" (0x800xBF) at the start of a character
  • A non-continuation byte (or the string ending) before the end of a character
  • An overlong encoding (0xE0 followed by less than 0xA0, or 0xF0 followed by less than 0x90)
  • A 4-byte sequence that decodes to a value greater than U+10FFFF (0xF4 followed by 0x90 or greater)

Many of the first UTF-8 decoders would decode these, ignoring incorrect bits. Carefully crafted invalid UTF-8 could make them either skip or create ASCII characters such as NUL, slash, or quotes, leading to security vulnerabilities. It is also common to throw an exception or truncate the string at an error[18] but this turns what would otherwise be harmless errors (i.e. "file not found") into a denial of service, for instance early versions of Python 3.0 would exit immediately if the command line or environment variables contained invalid UTF-8.[19]

RFC 3629 states "Implementations of the decoding algorithm MUST protect against decoding invalid sequences."[20] The Unicode Standard requires decoders to: "... treat any ill-formed code unit sequence as an error condition. This guarantees that it will neither interpret nor emit an ill-formed code unit sequence." The standard now recommends replacing each error with the replacement character "?" (U+FFFD) and continue decoding.

Some decoders consider the sequence E1,A0,20 (a truncated 3-byte code followed by a space) as a single error. This is not a good idea as a search for a space character would find the one hidden in the error. Since Unicode 6 (October 2010)[21] the standard (chapter 3) has recommended a "best practice" where the error is either one continuation byte, or ends at the first byte that is disallowed, so E1,A0,20 is a two-byte error followed by a space. This means an error is no more than three bytes long and never contains the start of a valid character, and there are 21,952 different possible errors. Technically this makes UTF-8 no longer a prefix code (the decoder has to read one byte past some errors to figure out if they are an error), but searching still works if the searched-for string does not contain any errors.

Making each byte be an error, in which case E1,A0,20 is two errors followed by a space, also still allows searching for a valid string. This means there are only 128 different errors which makes it practical to store the errors in the output string,[22] or replace them with characters from a legacy encoding.

Only a small subset of possible byte strings are error-free UTF-8: several bytes cannot appear; a byte with the high bit set cannot be alone; and in a truly random string a byte with a high bit set has only a 1?15 chance of starting a valid UTF-8 character. This has the consequence of making it easy to detect if a legacy text encoding is accidentally used instead of UTF-8, making conversion of a system to UTF-8 easier and avoiding the need to require a Byte Order Mark or any other metadata.

Surrogates

[edit]

Since RFC 3629 (November 2003), the high and low surrogates used by UTF-16 (U+D800 through U+DFFF) are not legal Unicode values, and their UTF-8 encodings must be treated as an invalid byte sequence.[20] These encodings all start with 0xED followed by 0xA0 or higher. This rule is often ignored as surrogates are allowed in Windows filenames and this means there must be a way to store them in a string.[23] UTF-8 that allows these surrogate halves has been (informally) called WTF-8,[24] while another variation that also encodes all non-BMP characters as two surrogates (6 bytes instead of 4) is called CESU-8.

Byte-order mark

[edit]

If the Unicode byte-order mark U+FEFF is at the start of a UTF-8 file, the first three bytes will be 0xEF, 0xBB, 0xBF.

The Unicode Standard neither requires nor recommends the use of the BOM for UTF-8, but warns that it may be encountered at the start of a file trans-coded from another encoding.[25] While ASCII text encoded using UTF-8 is backward compatible with ASCII, this is not true when Unicode Standard recommendations are ignored and a BOM is added. A BOM can confuse software that isn't prepared for it but can otherwise accept UTF-8, e.g. programming languages that permit non-ASCII bytes in string literals but not at the start of the file. Nevertheless, there was and still is software that always inserts a BOM when writing UTF-8, and refuses to correctly interpret UTF-8 unless the first character is a BOM (or the file only contains ASCII).[26]

Comparison to UTF-16

[edit]

For a long time there was considerable argument as to whether it was better to process text in UTF-16 or in UTF-8.

The primary advantage of UTF-16 is that the Windows API required it for access to all Unicode characters (UTF-8 was not fully supported in Windows until May 2019). This caused several libraries such as Qt to also use UTF-16 strings which propagates this requirement to non-Windows platforms.

In the early days of Unicode there were no characters greater than U+FFFF and combining characters were rarely used, so the 16-bit encoding was effectively fixed-size. Some believed fixed-size encoding could make processing more efficient, but any such advantages were lost as soon as UTF-16 became variable width as well.

The code points U+0800U+FFFF take 3 bytes in UTF-8 but only 2 in UTF-16. This led to the idea that text in Chinese and other languages would take more space in UTF-8. However, text is only larger if there are more of these code points than 1-byte ASCII code points, and this rarely happens in the real-world documents due to spaces, newlines, digits, punctuation, English words, and markup.

UTF-8 has the advantages of being trivial to retrofit to any system that could handle an extended ASCII, not having byte-order problems, and taking about half the space for any language using mostly Latin letters.

Implementations and adoption

[edit]
Declared character set for the 10 million most popular websites from 2010 to 2021
Use of the main encodings on the web from 2001 to 2012 as recorded by Google,[27] with UTF-8 overtaking all others in 2008 and over 60% of the web in 2012 (since then approaching 100%). UTF-8 is the only encoding of Unicode (explicitly) listed there, and the rest only provide subsets of Unicode. The ASCII-only figure includes all web pages that only contain ASCII characters, regardless of the declared header.

UTF-8 has been the most common encoding for the World Wide Web since 2008.[28] As of July 2025, UTF-8 is used by 98.7% of surveyed web sites.[2] Although many pages only use ASCII characters to display content, very few websites now declare their encoding to only be ASCII instead of UTF-8.[29] Virtually all countries and languages have 95% or more use of UTF-8 encodings on the web.

Many standards only support UTF-8, e.g. JSON exchange requires it (without a byte-order mark (BOM)).[30] UTF-8 is also the recommendation from the WHATWG for HTML and DOM specifications, and stating "UTF-8 encoding is the most appropriate encoding for interchange of Unicode"[5] and the Internet Mail Consortium recommends that all e?mail programs be able to display and create mail using UTF-8.[31][32] The World Wide Web Consortium recommends UTF-8 as the default encoding in XML and HTML (and not just using UTF-8, also declaring it in metadata), "even when all characters are in the ASCII range ... Using non-UTF-8 encodings can have unexpected results".[33]

Many software programs have the ability to read/write UTF-8. It may require the user to change options from the normal settings, or may require a BOM (byte-order mark) as the first character to read the file. Examples of software supporting UTF-8 include Microsoft Word,[34][35][36] Microsoft Excel (2016 and later),[37][38] Google Drive, LibreOffice,[39] and most databases.

Software that "defaults" to UTF-8 (meaning it writes it without the user changing settings, and it reads it without a BOM) has become more common since 2010.[40] Windows Notepad, in all currently supported versions of Windows, defaults to writing UTF-8 without a BOM (a change from Windows 7 Notepad), bringing it into line with most other text editors.[41] Some system files on Windows 11 require UTF-8[42] with no requirement for a BOM, and almost all files on macOS and Linux are required to be UTF-8 without a BOM.[citation needed] Programming languages that default to UTF-8 for I/O include Ruby 3.0,[43][44] R 4.2.2,[45] Raku and Java 18.[46] Although the current version of Python requires an option to open() to read/write UTF-8,[47] plans exist to make UTF-8 I/O the default in Python 3.15.[48] C++23 adopts UTF-8 as the only portable source code file format.[49]

Backwards compatibility is a serious impediment to changing code and APIs using UTF-16 to use UTF-8, but this is happening. As of May 2019, Microsoft added the capability for an application to set UTF-8 as the "code page" for the Windows API, removing the need to use UTF-16; and more recently has recommended programmers use UTF-8,[50] and even states "UTF-16 [...] is a unique burden that Windows places on code that targets multiple platforms".[4] The default string primitive in Go,[51] Julia, Rust, Swift (since version 5),[52] and PyPy[53] uses UTF-8 internally in all cases. Python (since version 3.3) uses UTF-8 internally for Python C API extensions[54][55] and sometimes for strings[54][56] and a future version of Python is planned to store strings as UTF-8 by default.[57][58] Modern versions of Microsoft Visual Studio use UTF-8 internally.[59] Microsoft's SQL Server 2019 added support for UTF-8, and using it results in a 35% speed increase, and "nearly 50% reduction in storage requirements."[60]

Java internally uses UTF-16 for the char data type and, consequentially, the Character, String, and the StringBuffer classes,[61] but for I/O uses Modified UTF-8 (MUTF-8), in which the null character U+0000 uses the two-byte overlong encoding 0xC00x80, instead of just 0x00.[62] Modified UTF-8 strings never contain any actual null bytes but can contain all Unicode code points including U+0000,[63] which allows such strings (with a null byte appended) to be processed by traditional null-terminated string functions. Java reads and writes normal UTF-8 to files and streams,[64] but it uses Modified UTF-8 for object serialization,[65][66] for the Java Native Interface,[67] and for embedding constant strings in class files.[63] The dex format defined by Dalvik also uses the same modified UTF-8 to represent string values.[68] Tcl also uses the same modified UTF-8[69] as Java for internal representation of Unicode data, but uses strict CESU-8 for external data. All known Modified UTF-8 implementations also treat the surrogate pairs as in CESU-8.

The Raku programming language (formerly Perl 6) uses utf-8 encoding by default for I/O (Perl 5 also supports it); though that choice in Raku also implies "normalization into Unicode NFC (normalization form canonical). In some cases the user will want to ensure no normalization is done; for this utf8-c8" can be used.[70] That UTF-8 Clean-8 variant, implemented by Raku, is an encoder/decoder that preserves bytes as is (even illegal UTF-8 sequences) and allows for Normal Form Grapheme synthetics.[71]

Version 3 of the Python programming language treats each byte of an invalid UTF-8 bytestream as an error (see also changes with new UTF-8 mode in Python 3.7[72]); this gives 128 different possible errors. Extensions have been created to allow any byte sequence that is assumed to be UTF-8 to be losslessly transformed to UTF-16 or UTF-32, by translating the 128 possible error bytes to 128 reserved code points, and transforming those code points back to error bytes to output UTF-8. The most common approach is to translate the codes to U+DC80...U+DCFF which are low (trailing) surrogate values and thus "invalid" UTF-16, as used by Python's PEP 383 (or "surrogateescape") approach.[22] Another encoding called MirBSD OPTU-8/16 converts them to U+EF80...U+EFFF in a Private Use Area.[73] In either approach, the byte value is encoded in the low eight bits of the output code point. These encodings are needed if invalid UTF-8 is to survive translation to and then back from the UTF-16 used internally by Python, and as Unix filenames can contain invalid UTF-8 it is necessary for this to work.[74]

Standards

[edit]

The official name for the encoding is UTF-8, the spelling used in all Unicode Consortium documents. The hyphen-minus is required and no spaces are allowed. Some other names used are:

There are several current definitions of UTF-8 in various standards documents:

  • RFC 3629 / STD 63 (2003), which establishes UTF-8 as a standard internet protocol element
  • RFC 5198 defines UTF-8 NFC for Network Interchange (2008)
  • ISO/IEC 10646:2020/Amd 1:2023[84]
  • The Unicode Standard, Version 16.0.0 (2024)[85]

They supersede the definitions given in the following obsolete works:

  • The Unicode Standard, Version 2.0, Appendix A (1996)
  • ISO/IEC 10646-1:1993 Amendment 2 / Annex R (1996)
  • RFC 2044 (1996)
  • RFC 2279 (1998)
  • The Unicode Standard, Version 3.0, §2.3 (2000) plus Corrigendum #1 : UTF-8 Shortest Form (2000)
  • Unicode Standard Annex #27: Unicode 3.1 (2001)[86]
  • The Unicode Standard, Version 5.0 (2006)[87]
  • The Unicode Standard, Version 6.0 (2010)[88]

They are all the same in their general mechanics, with the main differences being on issues such as allowed range of code point values and safe handling of invalid input.

See also

[edit]

References

[edit]
  1. ^ "Chapter 2. General Structure". The Unicode Standard (6.0 ed.). Mountain View, California, US: The Unicode Consortium. ISBN 978-1-936213-01-6.
  2. ^ a b "Usage Survey of Character Encodings broken down by Ranking". W3Techs. July 2025. Retrieved 2025-08-05.
  3. ^ "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
  4. ^ a b "UTF-8 support in the Microsoft GDK". Microsoft Learn. Microsoft Game Development Kit (GDK). Retrieved 2025-08-05.
  5. ^ a b "Encoding Standard". encoding.spec.whatwg.org. Retrieved 2025-08-05.
  6. ^ "File System Safe UCS — Transformation Format (FSS-UTF) - X/Open Preliminary Specification" (PDF). unicode.org.
  7. ^ "Appendix F. FSS-UTF / File System Safe UCS Transformation format" (PDF). The Unicode Standard 1.1. Archived (PDF) from the original on 2025-08-05. Retrieved 2025-08-05.
  8. ^ Whistler, Kenneth (2025-08-05). "FSS-UTF, UTF-2, UTF-8, and UTF-16". Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  9. ^ a b c Pike, Rob (2025-08-05). "UTF-8 history". Retrieved 2025-08-05.
  10. ^ At that time subtraction was slower than bit logic on many computers, and speed was considered necessary for acceptance.[citation needed]
  11. ^ Pike, Rob; Thompson, Ken (1993). "Hello World or Καλημ?ρα κ?σμε or こんにちは 世界" (PDF). Proceedings of the Winter 1993 USENIX Conference.
  12. ^ "USENIX Winter 1993 Conference Proceedings". usenix.org.
  13. ^ Alvestrand, Harald T. (January 1998). IETF Policy on Character Sets and Languages. IETF. doi:10.17487/RFC2277. BCP 18. RFC 2277.
  14. ^ Pike, Rob (2025-08-05). "UTF-8 turned 20 years old yesterday". Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  15. ^ Lunde, Ken (2025-08-05). "2022 Top Ten List: Why Support Beyond-BMP Code Points?". Medium. Retrieved 2025-08-05.
  16. ^ Marin, Marvin (2025-08-05). Windows NT UNICODE vulnerability analysis. Web server folder traversal. SANS Institute (Report). Malware FAQ. MS00-078. Archived from the original on Aug 27, 2014.
  17. ^ "CVE-2008-2938". National Vulnerability Database (nvd.nist.gov). U.S. National Institute of Standards and Technology. 2008.
  18. ^ "DataInput". docs.oracle.com. Java Platform SE 8. Retrieved 2025-08-05.
  19. ^ "Non-decodable bytes in system character interfaces". python.org. 2025-08-05. Retrieved 2025-08-05.
  20. ^ a b Yergeau, F. (November 2003). UTF-8, a transformation format of ISO 10646. IETF. doi:10.17487/RFC3629. STD 63. RFC 3629. Retrieved August 20, 2020.
  21. ^ Unicode 6.0.0. unicode.org (Report). October 2010.
  22. ^ a b von L?wis, Martin (2025-08-05). "Non-decodable Bytes in System Character Interfaces". Python Software Foundation. PEP 383.
  23. ^ "Change Windows filesystem encoding to UTF-8". Python.org. PEP 529. Retrieved 2025-08-05.
  24. ^ "The WTF-8 encoding".
  25. ^ "Chapter 2" (PDF), The Unicode Standard — Version 15.0.0, p. 39
  26. ^ "UTF-8 and Unicode FAQ for Unix/Linux".
  27. ^ Davis, Mark (2025-08-05). "Unicode over 60 percent of the web". Official Google blog. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  28. ^ Davis, Mark (2025-08-05). "Moving to Unicode 5.1". Official Google blog. Retrieved 2025-08-05.
  29. ^ "Usage statistics and market share of ASCII for websites". W3Techs. January 2025. Retrieved 2025-08-05.
  30. ^ Bray, Tim (December 2017). Bray, Tim (ed.). The JavaScript Object Notation (JSON) Data Interchange Format. IETF. doi:10.17487/RFC8259. RFC 8259. Retrieved 16 February 2018.
  31. ^ "Using International Characters in Internet Mail". Internet Mail Consortium. 2025-08-05. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  32. ^ "Encoding Standard". encoding.spec.whatwg.org. Retrieved 2025-08-05.
  33. ^ "Specifying the document's character encoding". HTML 5.2 (Report). World Wide Web Consortium. 14 December 2017. Retrieved 2025-08-05.
  34. ^ "Choose text encoding when you open and save files". Microsoft Support (support.microsoft.com). Retrieved 2025-08-05.
  35. ^ "UTF-8 - Character encoding of Microsoft Word DOC and DOCX files?". Stack Overflow. Retrieved 2025-08-05.
  36. ^ "Exporting a UTF-8 .txt file from Word". support.3playmedia.com. 14 March 2023.
  37. ^ "Are XLSX files UTF-8 encoded, by definition?". Stack Overflow. Excel. Retrieved 2025-08-05.
  38. ^ Abhinav, Ankit; Xu, Jazlyn (April 13, 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 Support Community. Retrieved 2025-08-05.
  39. ^ "Save a CSV file as UTF-8". RO CSVI. LibreOffice. Retrieved 2025-08-05.
  40. ^ Galloway, Matt (October 2012). "Character encoding for iOS developers; or, UTF-8 what now?". www.galloway.me.uk. Retrieved 2025-08-05. ... in reality, you usually just assume UTF-8 since that is by far the most common encoding.
  41. ^ "Windows 10 Notepad is getting better UTF-8 encoding support". BleepingComputer. Retrieved 2025-08-05. Microsoft is now defaulting to saving new text files as UTF-8 without BOM, as shown below.
  42. ^ "Customize the Windows 11 Start menu". docs.microsoft.com. Retrieved 2025-08-05. Make sure your LayoutModification.json uses UTF-8 encoding.
  43. ^ "Set default for Encoding.default_external to UTF-8 on Windows". Ruby Issue Tracking System (bugs.ruby-lang.org). Ruby master. Feature #16604. Retrieved 2025-08-05.
  44. ^ "Feature #12650: Use UTF-8 encoding for ENV on Windows". Ruby Issue Tracking System (bugs.ruby-lang.org). Ruby master. Retrieved 2025-08-05.
  45. ^ "New features in R 4.2.0". R bloggers (r-bloggers.com). The Jumping Rivers Blog. 2025-08-05. Retrieved 2025-08-05.
  46. ^ "UTF-8 by default". openjdk.java.net. JEP 400. Retrieved 2025-08-05.
  47. ^ "add a new UTF-8 mode". peps.python.org. PEP 540. Retrieved 2025-08-05.
  48. ^ "Make UTF-8 mode default". peps.python.org. PEP 686. Retrieved 2025-08-05.
  49. ^ Support for UTF-8 as a portable source file encoding (PDF). open-std.org (Report). 2022. p2295r6.
  50. ^ "Use UTF-8 code pages in Windows apps". Microsoft Learn. 20 August 2024. Retrieved 2025-08-05.
  51. ^ "Source code representation". The Go Programming Language Specification. golang.org (Report). Retrieved 2025-08-05.
  52. ^ Tsai, Michael J. (21 March 2019). "UTF-8 string in Swift 5" (blog post). Retrieved 2025-08-05.
  53. ^ "PyPy v7.1 released; now uses UTF-8 internally for Unicode strings". Mattip. PyPy status blog. 2025-08-05. Retrieved 2025-08-05.
  54. ^ a b "Flexible String Representation". Python.org. PEP 393. Retrieved 2025-08-05.
  55. ^ "Common Object Structures". Python documentation. Retrieved 2025-08-05.
  56. ^ "Unicode objects and codecs". Python documentation. Retrieved 2025-08-05. UTF-8 representation is created on demand and cached in the Unicode object.
  57. ^ "PEP 623 – remove wstr from Unicode". Python.org. Retrieved 2025-08-05.
  58. ^ Wouters, Thomas (2025-08-05). "Python 3.12.0 beta 4 released". Python Insider (pythoninsider.blogspot.com) (blog post). Retrieved 2025-08-05. The deprecated wstr and wstr_length members of the C implementation of unicode objects were removed, per PEP 623.
  59. ^ "validate-charset (validate for compatible characters)". docs.microsoft.com. Retrieved 2025-08-05. Visual Studio uses UTF-8 as the internal character encoding during conversion between the source character set and the execution character set.
  60. ^ "Introducing UTF-8 support for SQL Server". techcommunity.microsoft.com. 2025-08-05. Retrieved 2025-08-05.
  61. ^ "Character (Java SE 24 & JDK 24)". Oracle Corporation. 2025. Retrieved 2025-08-05.
  62. ^ "Java SE documentation for Interface java.io.DataInput, subsection on Modified UTF-8". Oracle Corporation. 2015. Retrieved 2025-08-05.
  63. ^ a b "The Java Virtual Machine Specification, section 4.4.7: "The CONSTANT_Utf8_info Structure"". Oracle Corporation. 2015. Retrieved 2025-08-05.
  64. ^ InputStreamReader and OutputStreamWriter
  65. ^ "Java Object Serialization Specification, chapter 6: Object Serialization Stream Protocol, section 2: Stream Elements". Oracle Corporation. 2010. Retrieved 2025-08-05.
  66. ^ DataInput and DataOutput
  67. ^ "Java Native Interface Specification, chapter 3: JNI Types and Data Structures, section: Modified UTF-8 Strings". Oracle Corporation. 2015. Retrieved 2025-08-05.
  68. ^ "ART and Dalvik". Android Open Source Project. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  69. ^ "UTF-8 bit by bit". Tcler's Wiki. 2025-08-05. Retrieved 2025-08-05.
  70. ^ "encoding | Raku Documentation". docs.raku.org. Retrieved 2025-08-05.
  71. ^ "Unicode | Raku Documentation". docs.raku.org. Retrieved 2025-08-05.
  72. ^ "PEP 540 -- Add a new UTF-8 Mode". Python.org. Retrieved 2025-08-05.
  73. ^ "RTFM optu8to16(3), optu8to16vis(3)". www.mirbsd.org.
  74. ^ Davis, Mark; Suignard, Michel (2014). "3.7 Enabling Lossless Conversion". Unicode Security Considerations. Unicode Technical Report #36.
  75. ^ "Encoding Standard § 4.2. Names and labels". WHATWG. Retrieved 2025-08-05.
  76. ^ "Character Sets". Internet Assigned Numbers Authority. 2025-08-05. Retrieved 2025-08-05.
  77. ^ "BOM". suikawiki (in Japanese). Archived from the original on 2025-08-05.
  78. ^ Davis, Mark. "Forms of Unicode". IBM. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  79. ^ Liviu (2025-08-05). "UTF-8 codepage 65001 in Windows 7 - part I". Retrieved 2025-08-05. Previously under XP (and, unverified, but probably Vista, too) for loops simply did not work while codepage 65001 was active
  80. ^ "MySQL :: MySQL 8.0 Reference Manual :: 10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)". MySQL 8.0 Reference Manual. Oracle Corporation. Retrieved 2025-08-05.
  81. ^ "MySQL :: MySQL 8.0 Reference Manual :: 10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)". MySQL 8.0 Reference Manual. Oracle Corporation. Retrieved 2025-08-05.
  82. ^ "Database Globalization Support Guide". docs.oracle.com. Retrieved 2025-08-05.
  83. ^ "HP PCL Symbol Sets | Printer Control Language (PCL & PXL) Support Blog". 2025-08-05. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  84. ^ ISO/IEC 10646.
  85. ^ The Unicode Standard, Version 16.0 §3.9 D92, §3.10 D95, 2021.
  86. ^ Unicode Standard Annex #27: Unicode 3.1, 2001.
  87. ^ The Unicode Standard, Version 5.0 §3.9–§3.10 ch. 3, 2006.
  88. ^ The Unicode Standard, Version 6.0 §3.9 D92, §3.10 D95, 2010.
[edit]
硕字五行属什么 乐松是什么药 阳痿早泄用什么药 女性尿酸低是什么原因 手信是什么
白蚂蚁长什么样子图片 男性内分泌失调吃什么药 心慌吃什么药好 eo什么意思 痛风挂什么科就医
胃肠紊乱吃什么药 五月初十是什么星座 停休是什么意思 什么地方能出生入死 dr是什么
妈妈的姐妹叫什么 甲亢的早期症状是什么 油耳是什么意思 什么茶降尿酸 丹毒是什么原因引起的
两侧肋骨疼是什么原因hcv8jop8ns6r.cn 什么情况下安装心脏起搏器hcv7jop7ns1r.cn 洋葱不能跟什么一起吃hcv8jop3ns8r.cn 什么是党的性质和宗旨的体现huizhijixie.com 什么是共济失调hcv8jop7ns3r.cn
二级建造师什么时候出成绩xjhesheng.com 腊月二十三是什么星座wzqsfys.com 思维敏捷是什么意思hcv8jop1ns7r.cn 吃什么能升血小板kuyehao.com 经常做梦是什么原因hcv8jop7ns0r.cn
sakose是什么牌子hcv9jop3ns8r.cn 五谷指什么hcv8jop9ns2r.cn 郑声是什么意思hcv9jop6ns1r.cn 莓茶是什么茶wuhaiwuya.com 史密斯夫妇什么意思hcv8jop8ns0r.cn
大葱炒什么好吃hcv9jop0ns4r.cn 胎盘成熟度1级是什么意思hcv8jop4ns5r.cn 湿疹为什么反反复复好不了hcv8jop7ns1r.cn 桂鱼吃什么食物hcv7jop6ns8r.cn 神疲乏力吃什么中成药hcv9jop6ns7r.cn
百度