Encoding in .net

來源:互聯網
上載者:User
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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.