gpt4 book ai didi

utf-8 - 无效的 UTF-8 字节

转载 作者:行者123 更新时间:2023-12-02 08:42:32 34 4
gpt4 key购买 nike

根据Wikipedia :

Not all sequences of bytes are valid UTF-8. A UTF-8 decoder should beprepared for:

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 Á
这些字节序列有对应的字符,但不应该有。我做错了吗?

最佳答案

你只是混淆了术语:

代码点 U+00C0 是字符“À”,U+00C1 是“Á”。
以 UTF-8 编码,它们是 字节序列 C3 80C3 81分别。

字节 C0C1永远不应该出现在 UTF-8 编码中。

代码点表示独立于字节的字符。字节就是字节。

关于utf-8 - 无效的 UTF-8 字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15325009/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com