方法一
复制代码
1
2
3
4string s = "u767bu5f55u6210u529fuff0cu6b63u5728u8df3u8f6c..."; System.Text.UnicodeEncoding encodingUNICODE = new System.Text.UnicodeEncoding(); encodingUNICODE.GetString(new UnicodeEncoding().GetBytes(s));
方法二:
复制代码
1Regex.Unescape(s);
方法三:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21public string FromUnicodeString(string str, string SplitString = "u") { string regexCode = SplitString == "u" ? "\\u(\w{1,4})" : SplitString + "(\w{1,4})"; string reString = str; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regexCode); System.Text.RegularExpressions.MatchCollection mc = reg.Matches(reString); for (int i = 0; i < mc.Count; i++) { try { var outs = (char)int.Parse(mc[i].Groups[1].Value, System.Globalization.NumberStyles.HexNumber); str = str.Replace(mc[i].Groups[0].Value, outs.ToString()); } catch { continue; } } return str; }
最后
以上就是稳重钻石最近收集整理的关于C#中Unicode转汉字的全部内容,更多相关C#中Unicode转汉字内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复