今天编程遇到了ANSI与UTF-8间的问题,查阅了相关资料,并对ANSI、Unicode、Unicode big endian、UTF-8四种编码方式进行了对比:
类型 |
字符串1 |
十六进制数 |
字符串2 |
十六进制数 |
ANSI |
“1” |
31 |
“12” |
31 32 |
Unicode |
“1” |
FF FE 31 00 |
“12” |
FF FE 31 00 32 00 |
Unicode big endian |
“1” |
FE FF 00 31 |
“12” |
FE FF 00 31 00 32 |
UTF-8 |
“1” |
EF BB BF 31 |
“12” |
EF BB BF 31 32 |
类型 |
字符串3 |
十六进制数 |
字符串4 |
十六进制数 |
ANSI |
“123” |
31 32 33 |
“1234” |
31 32 33 34 |
Unicode |
“123” |
FF FE 31 00 32 00 33 00 |
“1234” |
FF FE 31 00 32 00 33 00 34 00 |
Unicode big endian |
“123” |
FE FF 00 31 00 32 00 33 |
“1234” |
FE FF 00 31 00 32 00 33 00 34 |
UTF-8 |
“123” |
EF BB BF 31 32 33 |
“1234” |
EF BB BF 31 32 33 34 |
类型 |
字符串4 |
十六进制数 |
ANSI |
“1234文件” |
31 32 33 34 CE C4 BC FE |
Unicode |
“1234文件” |
FF FE 31 00 32 00 33 00 34 00 87 65 F6 4E |
Unicode big endian |
“1234文件” |
FE FF 00 31 00 32 00 33 00 34 65 87 4E F6 |
UTF-8 |
“1234文件” |
EF BB BF 31 32 33 34 E6 96 87 E4 BB B6 |