using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; namespace Mini.Common { public static class CommpnHelpEx { /// /// unicode编码 /// /// /// public static string ToUnicodeString(this string str) { StringBuilder strResult = new StringBuilder(); if (!string.IsNullOrEmpty(str)) { for (int i = 0; i < str.Length; i++) { strResult.Append("\\u"); strResult.Append(((int)str[i]).ToString("x")); } } return strResult.ToString(); } /// /// unicode解码 /// /// /// public static string FromUnicodeString(this string str) { if (string.IsNullOrEmpty(str)) return str; return System.Text.RegularExpressions.Regex.Unescape(str); } } }