Deep understanding of URL encoding in the Web

Source: Internet
Author: User

Web development is inseparable from Url,url is the Web site, network standards: only letters and numbers [0-9a-za-z], some special symbols "$-_. + ! * ' (), "[does not include double brackets], and some reserved words can be used without encoding directly for URLs.

Therefore, in order for our URLs to be able to access the normal, we often need to url--that is the network address, encoding and then access, there are two common situations:

① when an HTTP request is sent via the Get or post method;

② when sending requests via Ajax;

When sending an HTTP request via the Get or post method, there are two main ways to determine the encoding of the Web page:

One is to set the code on the head of the page:

<meta http-equiv= "Content-type" content= "text/html;charset=xxxx" >

The second is to set the encoding in the form:

<form action= "form_action.asp" accept-charset= "xxxx" >

When sending requests through Ajax, the encoding is usually handled by the browser, for example, no matter what character set your Web page uses, ie always uses "GB2312" to encode, and Firefox, Chrome always uses "UTF-8" to encode.

Now that the request is different and the browser is different, it will lead to a change in encoding, so what should we do to avoid the great trouble of coding the difference? In fact, there are ways to:

Full read >> Click me;

Deep understanding of URL encoding in the Web

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.