当前位置: 代码迷 >> Web Service >> .net调用java的webservice中文编码有关问题
  详细解决方案

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

热度:422   发布时间:2012-03-15 11:50:38.0
.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方法转回去就好了
  相关解决方案