查看汉字各种编码值

真有趣,gb2312和unicode是什么样,写到文件中也是什么样,而utf8是加上FFFE的头,然后转换成unicode写到文件中 

string s = "好";
   
   byte[] ascii = Encoding.ASCII.GetBytes(s); //1字节
   byte[] bigUnicode = Encoding.BigEndianUnicode.GetBytes(s);//2字节
   byte[] unicode = Encoding.Unicode.GetBytes(s);//2字节
   byte[] utf8 = Encoding.UTF8.GetBytes(s);//3字节
   byte[] utf7 = Encoding.UTF7.GetBytes(s);//5字节
   byte[] gb2312 = Encoding.GetEncoding("GB2312").GetBytes(s);//2字节

   FileStream fs1 = new FileStream(@"d:gb2312.txt",FileMode.Create);
   fs1.Write(gb2312,0,gb2312.Length);
   fs1.Close();

   FileStream fs2 = new FileStream(@"d:unicode.txt",FileMode.Create);
   fs2.Write(unicode, 0, unicode.Length);
   fs2.Close();

   FileStream fs3 = new FileStream(@"d:utf8.txt",FileMode.Create);
   fs3.Write(utf8,0,utf8.Length);
   fs3.Close();

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值