【发布时间】:2013-03-10 17:07:10
【问题描述】:
根据Wikipedia:
并非所有字节序列都是有效的 UTF-8。 UTF-8 解码器应该是 准备:
1. the red invalid bytes in the above table 2. an unexpected continuation byte 3. a start byte not followed by enough continuation bytes 4. an Overlong Encoding as described above 5. A 4-byte sequence (starting with 0xF4) that decodes to a value greater than U+10FFFF
根据代码页布局,0xC0 和 0xC1 是无效的,并且不能出现在有效的 UTF-8 序列中。这是我为 CodePoints 0xC0 和 0xC1 提供的内容:
Byte 2 Byte 1 Num Char
11000011 10000000 192 À
11000011 10000001 193 Á
这些字节序列有对应的字符,但不应该有。我做错了吗?
【问题讨论】:
-
您混淆了代码点和代码单元。
-
这两行包含 {xc3+x80} -> xc0 -> 192 和 {xc3+x81} -> xc1 ->193(并且您似乎交换了 byte2 和 byte1)
-
@wildplasser,你可以从位序列中猜测。