27

重複の可能性:
すべての文字をエンコードするのに 21 ビットしか必要ないのに、なぜ UTF-32 が存在するのですか?

Unicode の最大コード ポイントは、UTF-32 で 0x10FFFF です。UTF-32 には、21 の情報ビットと 11 の余分な空白ビットがあります。では、各コード ポイントを 4 バイトではなく 3 バイトで格納するための UTF-24 エンコーディング (つまり、上位バイトが削除された UTF-32) がないのはなぜでしょうか?

4

1 に答える 1

26

まあ、真実は: 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 よりも大きくなります。数学の英数字文字は、ほとんどの場合、UTF-8 を優先するのに十分な ASCII と組み合わされます。そうでない場合は、UTF-16 を優先するのに十分な BMP 文字と組み合わされます。最近のコンピューターは 24 ビット チャンクをうまく処理できません。メモリ内では、パックされていると宣言しない限り、1 ピースあたり 32 ビットを消費し、UTF-16 や UTF-32 よりもはるかに遅くなります。また、ディスクに保存する場合は、BOCU または SCSU を使用することもできます (すでに非標準になっています)。UTF-8、UTF-16、BOCU または SCSU で標準圧縮を使用することもできます。圧縮された SCSU または BOCU は、UTF-24 の半分のスペースを占有するはずです。

次の StackOverflow の投稿も確認できます。

すべての文字をエンコードするのに 21 ビットしか必要ないのに、なぜ UTF-32 が存在するのですか?

于 2012-04-13T15:36:54.813 に答える