读书人

.net调用java的webservice中文编码有关

发布时间: 2012-03-15 11:50:38 作者: rapoo

.net调用java的webservice中文编码问题
通过抓包发现正常的中文编码是 &#x6210 字样的

我通过编码函数:
public static string Encode(string strEncode)
{
string result = ""; string strReturn = "";
foreach (char stritem in strEncode)
{
strReturn = "";// 存储转换后的编码
foreach (short shortx in stritem.ToString().ToCharArray())
{
strReturn += shortx.ToString("X4");
}
result +="&#x"+strReturn;
}
return result;

}
对传送的中文进行编码传递后抓包得到的是: &#x6210 这个是错误的
有没有办法把编码变为 &#x6210

[解决办法]
&本来就是&的转义字符
用UrlDecoder方法转回去就好了

读书人网 >Web Service

热点推荐