protected string GetUnicode(string text) { string result = ""; for (int i = 0; i < text.Length; i++) { if ((int)text[i] > 32 && (int)text[i] < 127) { result += text[i].ToString(); } else result += string.Format("\\u{0:x4}", (int)text[i]); } return result; }
汉字转为Unicode编码
时间: 2024-11-28 23:17:19