商城名称: B2C测试 
定单号: WD-2008-1029393 
定单金额: RMB 0.02  
商品编号: abcd001  
商品名称: 灏忔甯  
商品数量: 1  
-----------------------
在说明文档里面有:
1、数据中不能包含“|”“&”“=”,此字符为银行端程序保留字符;中文变量使用GBK编码,另请注意与C2C接口定义字段名称和大小写有区分那我的
<input name="goodsName" type="text" value='<%= ProductName  %>'>
这个ProductName 要怎么转换谢谢

解决方案 »

  1.   


            string unicodeString = "小毡帽";        // Create two different encodings.
            Encoding ascii = Encoding.GetEncoding(936);
            Encoding unicode = Encoding.Unicode;        // Convert the string into a byte[].
            byte[] unicodeBytes = unicode.GetBytes(unicodeString);        // Perform the conversion from one encoding to the other.
            byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);        // Convert the new byte[] into a char[] and then into a string.
            // This is a slightly different approach to converting to illustrate
            // the use of GetCharCount/GetChars.
            char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
            ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
            ProductName = new string(asciiChars);我用上面的这样转没有效果啊
    谢谢
      

  2.   

    前两天看到过这个,应该是要将数据库中取得的信息,生成链接地址,你本站的编码,都统一才行
    转:这个原因是提交给支付宝的时候编码格式不统一,目前支付宝支持GBK和utf-8编码.默认传递的是gbk编码,如果是utf-8格式的,必须_input_charset用这个参数指定为utf-8编码._input_charset= ‘utf-8’