C#的C/S程序引用Java的WebService得到的string字符串是乱码
知道是汉字编码的问题,但是无法解决。方法一:strings="%3C%3Fxml+version%3D%221.0%22+encoding%3D%22GBK%2...
知道是汉字编码的问题,但是无法解决。方法一: string s = "%3C%3Fxml+version%3D%221.0%22+encoding%3D%22GBK%22%3F%3E%0A%3Croot%3E%0A%3Chead%3E%0A%3Ccode%3E-1%3C%2Fcode%3E%0A%3Cmessage%3E%E9%9D%9E%E6%B3%95%E8%B0%83%E7%94%A8%E5%9C%B0%E5%9D%80%21%3C%2Fmessage%3E%0A%3C%2Fhead%3E%0A%0A%3C%2Froot%3E"; byte[] bytes = System.Text.Encoding.GetEncoding("Unicode").GetBytes(s); s = System.Text.Encoding.GetEncoding("gb2312").GetString(bytes); 方法二: string i = "%3C%3Fxml+version%3D%221.0%22+encoding%3D%22GBK%22%3F%3E%0A%3Croot%3E%0A%3Chead%3E%0A%3Ccode%3E-1%3C%2Fcode%3E%0A%3Cmessage%3E%E9%9D%9E%E6%B3%95%E8%B0%83%E7%94%A8%E5%9C%B0%E5%9D%80%21%3C%2Fmessage%3E%0A%3C%2Fhead%3E%0A%0A%3C%2Froot%3E"; byte[] buffer1 = Encoding.GetEncoding("Unicode").GetBytes(i); byte[] buffer2 = Encoding.Convert(Encoding.GetEncoding("gb2312"), Encoding.GetEncoding("Unicode"), buffer1, 0, buffer1.Length); i = Encoding.GetEncoding("GBK").GetString(buffer2); 还有什么办法?
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询