zoukankan      html  css  js  c++  java
  • [转]c#Unicode转成汉字

     /// <summary>
            
    /// 把四个字符长度的Unicode转成对应的汉字
            
    /// </summary>
            
    /// <param name="str">长度是4的Unicode</param>
            
    /// <returns>对应的汉字,若转换出错则返回原字符串</returns>
            private string Unicode2UnitCharacter(string str)
            {
                if (str.Length != 4)
                {
                    return str;
                }

                try
                {
                    byte code = System.Convert.ToByte(str.Substring(02), 16);
                    byte code2 = System.Convert.ToByte(str.Substring(2), 16);
                    return System.Text.Encoding.Unicode.GetString(new byte[] { code2, code });
                }
                catch (Exception)
                {
                    return str;
                }

    原文

  • 相关阅读:
    [ASP.NET Core] Tips
    Integration_Unit test coding standard
    集成测试报错的解决方案
    Integration testing
    Web Cache
    BIT
    CSU 1449: A+B and C
    [转] CUDA + code::blocks 配置
    CF 245 div2
    NBUT 2014 C Lord of Minecraft
  • 原文地址:https://www.cnblogs.com/barrysgy/p/2361572.html
Copyright © 2011-2022 走看看