为啥没有 UTF-24? [复制]

Posted

技术标签:

【中文标题】为啥没有 UTF-24? [复制]【英文标题】:Why is there no UTF-24? [duplicate]为什么没有 UTF-24? [复制] 【发布时间】:2012-04-25 23:52:51 【问题描述】:

可能重复:Why UTF-32 exists whereas only 21 bits are necessary to encode every character?

在 UTF-32 中,最大的 Unicode 代码点是 0x10FFFF。 UTF-32 有 21 个信息位和 11 个多余的空白位。那么为什么没有 UTF-24 编码(即去掉高字节的 UTF-32)将每个代码点存储在 3 个字节而不是 4 个字节中?

【问题讨论】:

原因很简单,因为没有 24 结构。有 16、32、8、2,所以 24 是奇数。加上内存块通常以 2^x 块的形式提供。这与计算机没有配备 24MB 或 HDD 没有宣传 24GB 而不是 16GB 和 32GB 的原因相同。 【参考方案1】:

嗯,事实是:UTF-24 是在 2007 年提出的:

http://unicode.org/mail-arch/unicode-ml/y2007-m01/0057.html

提到的优点和缺点是:

"UTF-24 
Advantages: 
 1. Fixed length code units. 
 2. Encoding format is easily detectable for any content, even if mislabeled. 
 3. Byte order can be reliably detected without the use of BOM, even for single-code-unit data. 
 4. If octets are dropped / inserted, decoder can resync at next valid code unit. 
 5. Practical for both internal processing and storage / interchange. 
 6. Conversion to code point scalar values is more trivial then for UTF-16 surrogate pairs 
    and UTF-7/8 multibyte sequences. 
 7. 7-bit transparent version can be easily derived. 
 8. Most compact for texts in archaic scripts. 
Disadvantages: 
 1. Takes more space then UTF-8/16, except for texts in archaic scripts. 
 2. Comparing to UTF-32, extra bitwise operations required to convert to code point scalar values. 
 3. Incompatible with many legacy text-processing tools and protocols. "

正如 David Starner 在 http://www.mail-archive.com/unicode@unicode.org/msg16011.html 中指出的那样:

为什么? UTF-24 几乎总是比 UTF-16 大,除非你 正在谈论旧斜体或哥特体的文档。数学字母数字 字符几乎总是与足够的 ASCII 组合在一起 UTF-8 获胜,如果没有,足够的 BMP 字符使 UTF-16 获胜。 现代计算机不能很好地处理 24 位块。在记忆中,他们会 一块占用 32 位,除非您声明它们已打包,然后 它们会比 UTF-16 或 UTF-32 慢很多。如果你要存储到 磁盘,你也可以使用 BOCU 或 SCSU(你已经在 非标准),或使用标准压缩与 UTF-8、UTF-16、BOCU 或 南加州大学。 SCSU 或 BOCU 压缩后应该占用 UTF-24 一半的空间, 如果那样的话。

您还可以查看以下 *** 帖子:

Why UTF-32 exists whereas only 21 bits are necessary to encode every character?

【讨论】:

第二个引用实际上是几年前的,从 2003 年开始,是为了回复我的提议。 就个人而言,我希望看到它们扩展。我知道还有很多空间,但他们还没有完成所有语言,尤其是历史语言。 我相信在 Python 中,类似 UTF24 的字符串是默认的。

以上是关于为啥没有 UTF-24? [复制]的主要内容,如果未能解决你的问题,请参考以下文章

为啥没有@Transactional 我可以保存? [复制]

为啥没有登录异常堆栈跟踪? [复制]

为啥箭头函数没有参数数组? [复制]

为啥这个标签的内容没有居中? [复制]

为啥这里没有触发“输入”事件? [复制]

为啥接口成员没有访问修饰符? [复制]