实例如下:
public string unicodetogb(string text) { system.text.regularexpressions.matchcollection mc = system.text.regularexpressions.regex.matches(text, "\\\\u([\\w]{4})"); if (mc != null && mc.count > 0) { foreach (system.text.regularexpressions.match m2 in mc) { string v = m2.value; string word = v.substring(2); byte[] codes = new byte[2]; int code = convert.toint32(word.substring(0, 2), 16); int code2 = convert.toint32(word.substring(2), 16); codes[0] = (byte)code2; codes[1] = (byte)code; text = text.replace(v, encoding.unicode.getstring(codes)); } } else { } return text; }
以上这篇c#把unicode编码转换为gb编码的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论