|
|
1
4
在我看来,测试程序有很大的缺陷,因为它在没有语义的字符串之间进行了有效的无用转换。 如果要检查所有字节值是否都是给定编码的有效值,则类似于以下内容:
字节值 (相当于此范围内的Unicode代码点)从1到255。 尝试打印示例中程序处理的实际字节数组,您会发现实际上并没有检查所有字节值,并且一些“错误”匹配与其他匹配是重复的。
Can't encode: 129 - in: [-127]/ out: [63] - result: � Can't encode: 141 - in: [-115]/ out: [63] - result: � Can't encode: 143 - in: [-113]/ out: [63] - result: � Can't encode: 144 - in: [-112]/ out: [63] - result: � Can't encode: 157 - in: [-99]/ out: [63] - result: � Bad count: 5
这告诉我们
The Wikipedia article on Windows-1252
|
|
|
2
2
代码的作用是什么(
当然,当输入包含目标编码不支持的字符时,它将丢失数据。 |
|
|
Patrick · 将UTF-8转换为ANSI(windows-1252) 11 年前 |