• Unicode转字符串


    /// <summary>
            /// Unicode转字符串
            /// </summary>
            /// <returns>The to string.</returns>
            /// <param name="unicode">Unicode.</param>
            public static string UnicodeToString(this string unicode)
            {
                return System.Text.RegularExpressions.Regex.Unescape(str);
            }
    

      

    /// <summary>
        /// 字符串转Unicode码
        /// </summary>
        /// <returns>The to unicode.</returns>
        /// <param name="value">Value.</param>
        private string StringToUnicode(string value)
        {
            byte[] bytes = Encoding.Unicode.GetBytes (value);
            StringBuilder stringBuilder = new StringBuilder ();
            for (int i = 0; i < bytes.Length; i += 2) {
                // 取两个字符,每个字符都是右对齐。
                stringBuilder.AppendFormat ("u{0}{1}", bytes [i + 1].ToString ("x").PadLeft (2, '0'), bytes [i].ToString ("x").PadLeft (2, '0'));
            }
            return stringBuilder.ToString ();
        }
    

      

  • 相关阅读:
    iptables 学习
    linux frp 配置
    LINUX下安装TOMCAT 及JDK方法
    更改默认源pip
    重装ORACLE参考
    pandas入门学习
    python笔记
    redis 笔记
    STM32工程编译后TIM1时钟变慢的解决
    IAR工程编译错误问题
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/8677216.html
Copyright © 2020-2023  润新知