In the HTTP request if contains the Chinese character, then will appear garbled, the citation default encoding is the ISO, for the normal display, needs to convert the code to UTF or GBK, provides an auxiliary class below.
Import java.io.UnsupportedEncodingException;
/**
* Auxiliary class for Chinese character transcoding
* @date 2015-09-06 10:29:22
* @author GEENKDC
*
*/
public class iso2utf{
public static string Iso2utf (String isostr) {
String utfstr = null;
try {
Transcoding of Chinese characters in the import parameter
Utfstr = new String (isostr.getbytes ("iso-8859-1"), "UTF-8");
} catch (Unsupportedencodingexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
return utfstr;
}
public static string ISO2GBK (String isostr) {
String utfstr = null;
try {
Transcoding of Chinese characters in the import parameter
Utfstr = new String (isostr.getbytes ("iso-8859-1"), "GBK");
} catch (Unsupportedencodingexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
return utfstr;
}
}
Garbled------encoded conversions in HTTP requests