獲取轉UTF8的字符串
阿新 • • 發佈:2017-11-18
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)) {View Codereturn 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; }
獲取轉UTF8的字符串