分享

c#中GBK与UNICODE互转

 luan_it 2017-11-13

 unicode to GBK

 

 

    // aText 是 string类型,unicode编码

Encoding gbkencoding = Encoding.GetEncoding(936);

byte[] gbkBytes = gbkencoding.GetBytes(aText);

    //gbkBytes 中是GBK字节流

 

 

GBK to unicode

 

    // buff 是GBK字节数组

Encoding gbkencoding = Encoding.GetEncoding(936);
byte[] buf2 = Encoding.Convert(gbkencoding,Encoding.Unicode, buff);

string atext =Encoding.Unicode.GetString(buf2);

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多