文本编码格式是utf-8,请各位老大给点c#转换的例子。
我用
string gb2312info = string.Empty; byte[] unicodeBytes = _utf8.GetBytes(utf8info); byte[] asciiBytes = Encoding.Convert(_utf8, _gb2312, unicodeBytes); char[] asciiChars = new char[_gb2312.GetCharCount(asciiBytes, 0, asciiBytes.Length)]; _gb2312.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0); gb2312info = new string(asciiChars);
这段代码没有效果。返回的xml文本内容如下:其中的<LAYERINFO name>为乱码,想把它转为中文,有啥办法没?
<LAYERINFO type="featureclass" visible="false" name="楗簵" id="42">
<FCLASS type="point">
<ENVELOPE minx="120.251207" miny="30.766291138871" maxx="121.273427" maxy="32.002778" />
</FCLASS>
<SIMPLERENDERER>
<SIMPLEMARKERSYMBOL type="" transparency="0" width="8" />
</SIMPLERENDERER>
</LAYERINFO>
我用
string gb2312info = string.Empty; byte[] unicodeBytes = _utf8.GetBytes(utf8info); byte[] asciiBytes = Encoding.Convert(_utf8, _gb2312, unicodeBytes); char[] asciiChars = new char[_gb2312.GetCharCount(asciiBytes, 0, asciiBytes.Length)]; _gb2312.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0); gb2312info = new string(asciiChars);
这段代码没有效果。返回的xml文本内容如下:其中的<LAYERINFO name>为乱码,想把它转为中文,有啥办法没?
<LAYERINFO type="featureclass" visible="false" name="楗簵" id="42">
<FCLASS type="point">
<ENVELOPE minx="120.251207" miny="30.766291138871" maxx="121.273427" maxy="32.002778" />
</FCLASS>
<SIMPLERENDERER>
<SIMPLEMARKERSYMBOL type="" transparency="0" width="8" />
</SIMPLERENDERER>
</LAYERINFO>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货