1. 程式人生 > >獲取轉UTF8的字符串

獲取轉UTF8的字符串

lose str odin col 分享圖片 div bytes 3-9 trre

技術分享圖片
        /// <summary>
        /// 獲取轉UTF8的字符串
        /// </summary>
        /// <param name="strWord"></param>
        /// <returns></returns>
        public static string GetUtf8String(string strWord)
        {
            string strRes = string.Empty;

            if (string.IsNullOrEmpty(strWord))
            {
                
return strRes; } string s = BitConverter.ToString(System.Text.Encoding.UTF8.GetBytes(strWord)); foreach (byte b in Encoding.UTF8.GetBytes(s)) { strRes += % + b.ToString("X"); } return strRes; }
View Code

獲取轉UTF8的字符串