string u16s = "测试数据abc"; //默认的字符编码是unicode,也就是utf16
//4种编码
Encoding utf8 = Encoding.UTF8;
Encoding utf16 = Encoding.Unicode;
Encoding gb = Encoding.GetEncoding("gbk");
Encoding b5 = Encoding.GetEncoding("big5");
Encoding GB2313 = Encoding.GetEncoding("gb2313");
//转换得到4种编码的字节流
byte[] u16bytes = utf16.GetBytes(u16s);
byte[] u8bytes = Encoding.Convert(utf16, utf8, u16bytes);
byte[] gbytes = Encoding.Convert(utf16, gb, u16bytes);
byte[] bbytes = Encoding.Convert(utf16, b5, u16bytes);
Encoding数据格式转化
最新推荐文章于 2024-07-09 20:14:50 发布