Encoding escape, encodeURI, and encodeuricomponent__ encoding

Source: Internet
Author: User
one, Escape 1, the characteristic function is lets the string be readable on all computers. The effect of the encoding is%XX or%uxxxx this form. encoded character range: ASCII letters, numbers, @*/+, these characters will not be encoded, the rest will be. 2, suitable for the occasion

Strings Two, encodeURI 1, and feature spaces are encoded as "%20" encoded character ranges: ASCII letters, numbers, ~!@#$&* () =:/,;? + ' will not be coded, the other will be 2, suitable for the occasion

Because encodeURI does not encode ":" and "/" in the URL, use encodeURI if you need to encode and use the entire URL.

encodeURIComponent cannot be used because encodeURIComponent will encode ":" In the URL as "%3a" and "/" to encode "%2f"

This URL will not be accessible. Third, encodeURIComponent 1, features encoded character range: ASCII letters, numbers, ~!* () will not be encoded, others will be compared encodeURI can be found encodeuricomponent than encodeURI coding range. encodeURIComponent will encode http://as http%3a%2f%2f and encodeURI not. 2, suitable for the occasion

When you need to encode the parameters in the URL, then encodeURIComponent is the best way.

Because the "/" in the URL parameter needs to be encoded, otherwise an invalid path is created in the URL that affects access to the URL.

encodeURIComponent can encode "/", so it is appropriate to encode the parameters of the pairs in the URL.

encodeURI cannot encode "/", so it is not appropriate to encode the parameters in the URL.

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.