URL format conversion
Convert Chinese in utf-8 format to URL encoding encodestr = Urlencoder.encode (fname, "utf-8"); Converts a URL-encoded string into the Utf-8 format in Chinese decodefname = Urldecoder.decode (Encodestr, "utf-8");
string format conversion
@Testpublic void Test () {String teststr = "Medium"; try {//Get the specified encoded byte array string---> Byte array byte[] T_iso = teststr.getbytes ("iso8859-1"); byte[] T_GBK = teststr.getbytes ("GBK"); byte[] T_utf8 = teststr.getbytes ("UTF-8"); SYSTEM.OUT.PRINTLN ("Use ISO decode ..." + t_iso.length); System.out.println ("Decode with GBK ..." + t_gbk.length); System.out.println ("Decode with UTF8 ..." + t_utf8.length); After decoding in the assembly string ut_iso = new String (T_iso, "iso8859-1"); String UT_GBK = new String (T_GBK, "GBK"); String Ut_utf8 = new String (T_utf8, "UTF-8"); SYSTEM.OUT.PRINTLN ("Use ISO to decode and then assemble with ISO ..." + ut_iso); System.out.println ("Use GBK to decode and then assemble with GBK ..." + UT_GBK); System.out.println ("Use UTF8 to decode and then assemble with UTF8 ..." + Ut_utf8); Sometimes the requirements must be ISO character encoding type//can be encoded with Gbk/utf8, Iso8859-1 assembled into a string, decoding the reverse can get the correct Chinese character string t_utf8toiso = new String (T_u Tf8, "iso8859-1"); The ISO-encoded string is restored as String ut_utf8toiso = new String (t_utf8toiso.getbyteS ("Iso8859-1"), "UTF-8"); System.out.println ("Assemble UTF8 encoded characters using ISO ..." + t_utf8toiso); System.out.println ("Encode characters using ISO decoding UTF8 ..." + ut_utf8toiso); } catch (Unsupportedencodingexception e) {e.printstacktrace (); }}
Transferred from: https://www.cnblogs.com/ikuman/archive/2013/08/06/3238596.html
URL encoding Conversion