平台1 为java语言编写,进行post请求,请求编码方式为默认编码(给出编码说是iso-8859-1)参数为json串,
平台2为C#编写,为被请求方,接收写法为:  
byte[] requestData = new byte[Request.InputStream.Length];
            Request.InputStream.Read(requestData, 0, Request.InputStream.Length - 1);
            string req = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(requestData);
                --此处页用过utf-8,但是接收过来的数据中的中文都是乱码,不知道如何解决?请求各位大神支招。
没有分了,在这里拜谢了。

解决方案 »

  1.   

    已有8年 CSDN 网龄的人,不应问这个问题啊。
    与请求方仔细对接,是不是编码不对?如果对接不畅,多试试其他的编码,看哪个是对的。
      

  2.   

    iso-8859-1又称Latin-1或“西欧语言”。它本来就不支持中文
      

  3.   

    JSON规范是“JSON交换时必须编码为UTF-8”。你可以试试用UTF8解码。
      

  4.   

    一般来说,接口的编码规则由被调用方来定,接口开发者的职责。如果是公司内部之间的接口调用,那么你们自已商量好用utf-8就行了。 
      

  5.   

    看看这个,还有你那Read长度要减1?private static string ConvertISO88591ToEncoding(string srcString, Encoding dstEncode)
    {    String sResult;    Encoding ISO88591Encoding = Encoding.GetEncoding("ISO-8859-1");
        Encoding GB2312Encoding = Encoding.GetEncoding("GB2312"); //这个地方很特殊,必须利用GB2312编码
        byte[] srcBytes = ISO88591Encoding.GetBytes(srcString);     //将原本存储ISO-8859-1的字节数组当成GB2312转换成目标编码(关键步骤)
        byte[] dstBytes = Encoding.Convert(GB2312Encoding, dstEncode, srcBytes);    char[] dstChars = new char[dstEncode.GetCharCount(dstBytes, 0, dstBytes.Length)];         dstEncode.GetChars(dstBytes, 0, dstBytes.Length, dstChars, 0);//利用char数组存储字符
        sResult = new string(dstChars);
        return sResult;}