4

1バイトのゼロはutf16とutf32でnullを意味しますか?utf8のように、またはutf16とutf32でそれぞれnullを作成するには、2バイトと4バイトのゼロが必要ですか?

4

1 に答える 1

10

UTF-16では2バイトになり、UTF-32では4バイトになります。

結局のところ、そうでなければ、エンコードされた値がたまたまゼロバイトで始まった文字と、U+0000を表す単一のゼロバイトを区別できませんでした。

Basically UTF-16 works in blocks of 2 bytes, and UTF-32 works in blocks of 4 bytes. (Admittedly for characters outside the BMP you need two "blocks" of UTF-16, but the principle is still the same.) If you were to implement a UTF-16 decoder, you'd read two bytes at a time.

于 2010-04-21T18:57:14.947 に答える