zoukankan      html  css  js  c++  java
  • C# unicode 转中文

     //Unicode 转中文
      private void button1_Click(object sender, EventArgs e)
      {
         string unicode = @"U5fae";
    
         string result = string.Empty;
    
         string[] strlist = unicode.Replace("\", "").Split('U');
    
         string s = strlist[1];
    
        result = ((char)int.Parse(s, System.Globalization.NumberStyles.HexNumber)).ToString(); 
        MessageBox.Show(result);
    
    
      }
    
      private void button2_Click(object sender, EventArgs e)
     {
                string path = @"E:expexp.txt";
    
                string content = File.ReadAllText(path);
    
                string[] array = content.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
    
                StringBuilder sb = new StringBuilder();
    
                foreach (var item in array)
                {
                    string[] temp = item.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    sb.Append(temp[0]);
                    sb.Append("=");
    
                    sb.Append("[");
    
                    string str = temp[1].Trim().Trim('"','[',']');
    
    
                    if (Regex.IsMatch(str, @"^[A-Z]{2}$"))
                    {
    
                        sb.Append(str);
                    }
                    else
                    {
    
                        string[] strlist = str.Replace("\", "").Split(new char[] { 'U' }, StringSplitOptions.RemoveEmptyEntries);
    
                        string result = string.Empty;
    
                        foreach (var s in strlist)
                        {
                            result += ((char)int.Parse(s, System.Globalization.NumberStyles.HexNumber)).ToString();
                        }
    
                        sb.Append(result);
    
                    }
                    sb.Append("]");
    
                    sb.Append("
    ");
                }
    
    
                File.WriteAllText(@"E:expdemo.txt", sb.ToString());
    
                MessageBox.Show("转换成功");
    
            }

     

    上图 转为 下图

  • 相关阅读:
    TeX系列: tikz-3dplot绘图宏包
    TeX系列: MATLAB和LaTeX结合绘图
    Tex系列: pgfplots安装
    C 标准库
    C 标准库
    C 标准库
    C 标准库
    C 标准库
    C 标准库
    C 标准库
  • 原文地址:https://www.cnblogs.com/zoro-zero/p/4495685.html
Copyright © 2011-2022 走看看