Csharp/C#教程:C#把UNICODE编码转换为GB编码的实例分享

实例如下:

publicstringunicodetogb(stringtext) { System.Text.RegularExpressions.MatchCollectionmc=System.Text.RegularExpressions.Regex.Matches(text,"\\u([\w]{4})"); if(mc!=null&&mc.Count>0) { foreach(System.Text.RegularExpressions.Matchm2inmc) { stringv=m2.Value; stringword=v.Substring(2); byte[]codes=newbyte[2]; intcode=Convert.ToInt32(word.Substring(0,2),16); intcode2=Convert.ToInt32(word.Substring(2),16); codes[0]=(byte)code2; codes[1]=(byte)code; text=text.Replace(v,Encoding.Unicode.GetString(codes)); } } else { } returntext; }

上述就是C#学习教程:C#把UNICODE编码转换为GB编码的实例分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/907677.html

(0)
上一篇 2021年10月24日
下一篇 2021年10月24日

精彩推荐