根据维基百科UTF-8页面,我从人们那里听到了相互矛盾的观点。

它们是一样的,不是吗?有人能澄清一下吗?


当前回答

UTF-8是一种使用8位序列编码Unicode字符的方法。

Unicode是一种用于表示来自多种语言的各种字符的标准。

其他回答

UTF-8是一种使用8位序列编码Unicode字符的方法。

Unicode是一种用于表示来自多种语言的各种字符的标准。

如果我可以总结一下我从这篇文章中收集到的信息:

Unicode将字符分配给序数(十进制形式)。(这些数字被称为码位。)

à -> 224

UTF-8是一种将这些序数(十进制形式)“转换”为二进制表示的编码。

224 -> 11000011 10100000

注意,我们讨论的是224的二进制表示,而不是它的二进制形式,即0b11100000。

Unicode只定义码位,即代表一个字符的数字。如何在内存中存储这些代码点取决于所使用的编码。UTF-8是编码Unicode字符的一种方式。

作为一个直截了当的简单回答:

Unicode是一种表示多种人类语言字符的标准。 UTF-8是一种编码Unicode字符的方法。


是的:我故意忽略了UTF-8的内部工作原理。

它们是一样的,不是吗?

不,他们不是。


我认为你引用的维基百科页面的第一句话给出了一个很好的,简短的总结:

UTF-8是一种可变宽度字符编码,能够使用一到四个8位字节编码Unicode中的所有1,112,064个有效代码点。

阐述:

Unicode is a standard, which defines a map from characters to numbers, the so-called code points, (like in the example below). For the full mapping, you can have a look here. ! -> U+0021 (21), " -> U+0022 (22), \# -> U+0023 (23) UTF-8 is one of the ways to encode these code points in a form a computer can understand, aka bits. In other words, it's a way/algorithm to convert each of those code points to a sequence of bits or convert a sequence of bits to the equivalent code points. Note that there are a lot of alternative encodings for Unicode.


乔尔给出了一个非常好的解释,并概述了这里的历史。