本文共 398 字,大约阅读时间需要 1 分钟。
服务器本地编码:GBK
response 编码:ISO-8859-1(tomcat服务器默认response 编码ISO-8859-1)输出:GBK->ISO-8859-1正确方法:1、改变response编码 response.setCharacterEncoding("GBK");2、String result = new String(str.getByte("GBK"),"ISO-8859-1");输入:
1、如果response 是 ISO-8859-1:ISO-8859-1->GBK(这步是PHP自动的)2、如果response 是 GBK:GBK->GBK(这步是PHP自动的)php页面本身的编码:UTF-8正确方法 GBK->UTF-8:mb_convert_encoding(file_get_contents($url),"UTF-8","GBK");转载地址:http://fjdrj.baihongyu.com/