URL encoding Conversion

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.