zoukankan      html  css  js  c++  java
  • 查看汉字各种编码值

    真有趣,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();

  • 相关阅读:
    自定义线性表
    网站关键词抓住热点话题获取长尾关键词 给网站增添流量(图)
    Hibernate常见注解说明
    面试问题java基础
    Spring常见的注解说明
    poj3268
    poj3273
    poj3250
    poj3277
    poj3253
  • 原文地址:https://www.cnblogs.com/meil/p/644754.html
Copyright © 2011-2022 走看看