1
2
3
4
5
6
string strTmp = "a1某某某";
int a = System.Text.Encoding.Default.GetBytes(strTmp).Length;
int b = strTmp.Length;
//a = 11(1+1+3*3)
//b = 5
分析:在UTF-8編碼下,每個中文字元通常佔用3個位元組,而每個英文字元和數字佔用1個位元組。
UTF-8編碼一個中文字佔3 bytes,而BIG5編碼一個中文字佔2 bytes
1
2
3
4
5
6
string strTmp = "a1某某某";
int a = System.Text.Encoding.Default.GetBytes(strTmp).Length;
int b = strTmp.Length;
//a = 11(1+1+3*3)
//b = 5
分析:在UTF-8編碼下,每個中文字元通常佔用3個位元組,而每個英文字元和數字佔用1個位元組。
UTF-8編碼一個中文字佔3 bytes,而BIG5編碼一個中文字佔2 bytes
A new version of content is available.