2012-04-13 90 views
18

可能重复:
Why UTF-32 exists whereas only 21 bits are necessary to encode every character?为什么没有UTF-24?

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

+0

原因很简单,因为没有一个24的结构。有16,32,8,2,所以24是奇数。加上内存块通常会以2^x块的形式出现....其原因computere没有配备24MB或HDD的相同原因不会以24GB而不是16GB和32GB来标示。 – 2012-04-13 15:42:25

回答

19

嗯,事实是: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. " 

正如大卫指出,斯坦纳在http://www.mail-archive.com/[email protected]/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进行标准压缩。如果是这样,SCSU或BOCU压缩应占用UTF-24的一半空间,即 。

你也可以查看下面的StackOverflow职位:

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

+2

第二次报价实际上是在几年前,从2003年起,我回复了我的建议。 – 2012-07-16 15:06:17

+0

个人而言,我希望看到他们扩大。我知道还剩下很多空间,但他们还没有完成任何语言,尤其是历史语言。 – Rahly 2015-12-24 00:11:07