返回一個多字節如果我編碼以下字符串爲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