BOM: Byte Oder Mark
|
編碼 |
BOM值 |
|
UTF-8 |
EF BB BF |
|
UTF-16 big endian |
FE FF |
|
UTF-16 little endian (Unicode) |
FF FE |
|
UTF-32 big endian |
00 00 FE FF |
|
UTF-32 little endian |
FF FE 00 00 |
你可能不知道:一個漢字用utf-8編碼會用3個位元組。 NET中的StreamWriter預設採用UTF8編碼格式編碼字串,但並不將UTF8所對應的BOM值(“EF BB BF”)寫入到二進位流中。UTF8Encoding 的預設建構函式也不帶BOM,而Encoding.UTF8是帶BOM的。 DBCS double-byte character setSBCS single-byte character set 在中文環境下Encoding.Default屬性返回的類型是DBCSCodePageEncoding,這是一個internal的類
|
字碼頁標識值 |
.NET中的名字 |
|
936 |
gb2312 |
|
950 |
big5 |
|
1200 |
utf-16 |
|
52936 |
hz-gb-2312 |
|
54936 |
GB18030 |
|
65000 |
utf-7 |
|
65001 |
utf-8 |
|
932 |
Japanese Shift-JIS |
private static Encoding CreateDefaultEncoding()
{
int aCP = Win32Native.GetACP();
if (aCP == 0x4e4) //1252
{
return new SBCSCodePageEncoding(aCP);
}
return GetEncoding(aCP);
} http://www.cnblogs.com/bitfan/archive/2010/11/25/1887590.htmlhttp://en.wikipedia.org/wiki/Code_page
Published by Wiz