transcoding and decoding of URL parameters using Urlencoder, Urldecoder

Source: Internet
Author: User

Transcoding and decoding of parameters after URL

Import Java.net.urldecoder;import Java.net.URLEncoder;
" =abc?%1&2<3,4> " "UTF-8"); System. out = Urldecoder.decode (strtest,"UTF-8"); System. out . println (strtest);

Execution Result:

%3f%3dabc%3f%e4%b8%ad%251%262%3c3%2c4%3E=abc?%1&2<3 ,4>

Description of JDK:

string Java.net.URLEncoder.encode (string s, String enc) throws Unsupportedencodingexceptiontranslates astringinto application/x-www-form-urlencoded formatusingA specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafecharacters. Note:the World Wide Web Consortium recommendation states that UTF-8should be used. Not doing so may introduce incompatibilites.     Parameters:s String to is translated. Enc the name of a supported character encoding. Returns:the translated String. Throws:unsupportedencodingexception-If The named encoding isNot supported Since:1.4See Also:URLDecoder.decode (java.lang.String, java.lang.String) String Java.net.URLDecoder.decode (string s, Strin G enc) throws unsupportedencodingexceptiondecodes a application/x-www-form-urlencodedstring usingA specific encoding scheme. The supplied encoding isUsed to determine what characters is represented by any consecutive sequences of the form"%xy". Note:the World Wide Web Consortium recommendation states that UTF-8should be used. Not doing so may introduce incompatibilites. Parameters:s the String to decode enc the name of a supported character encoding. Returns:the newly decoded String throws:unsupportedencodingexception-If character encoding needs to being consulted, but named character encoding isNot supported Since:1.4See Also:URLEncoder.encode (java.lang.String, java.lang.String)

transcoding and decoding of URL parameters using Urlencoder, Urldecoder

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.