返回一个多字节如果我编码以下字符串为UTF8:编码欧洲字符
咖啡厅
它返回5个字节,而不是4,我想它如果可能的话,返回4个字节。
Encoding encoding = Encoding.UTF8;
string testString = "café";
Byte[] bytes = encoding.GetBytes(testString);
返回:
[0] 99
[1] 97
[2] 102
[3] 195
[4] 169
而 “网吧” 只返回4个字节。
?你的期望是什么?你期望UTF8将“é”转换为“e”吗? – 2012-08-17 00:15:49