Introduction to the use of special symbols in URLs _javascript tips

Source: Internet
Author: User
A URL, the Uniform Resource Locator, is a common resource identifier URI.

Because a valid URI cannot contain certain characters, such as spaces, you cannot access a valid resource if the URI is not encoded using the corresponding encoding function (the browser handles the corresponding URL).

JavaScript's Global object (JavaScript's built-in object) has four URI methods, encodeURI and Decodeuri,encodeuricomponent and decodeURIComponent, respectively. The browser model (BOM) provides escape and unescape. In practice, the URI method is preferable because the URI method encodes all Unicode symbols, and the escape and unescape provided by the BOM encode only ASCII symbols. In addition, Escape,unescape can be used to encrypt and decrypt data.

Where encodeURI and decodeURI are treated in the opposite way, encodeURIComponent and decodeURIComponent are doing the opposite, and escape and unescape do the opposite treatment.

encodeURI is to process the complete URI, while the encodeuricomponent handles the URI fragment, encodeURI the encoding except:! , #,¥,&, ', (,), x,+,,,-,.,/,:,;,=,? , @,_,~,0-9,a-z,a-z (a total of 82) characters, while the encodeURIComponent code except:!, ', (,), *,-,.,_,~,0-9,a-z,a-z (total 71) characters, Escape coding except: *,+,-, .,/,@,_,0-9,a-z,a-zs (a total of 61) characters.

The request server (server is a 64-bit operating system) end with a special character (+) of the file name, with encodeuri,decodeuricomponent or escape will prompt the corresponding resources do not exist, this is why?

JS Code:
Copy Code code as follows:

url = "Http://192.168.6.135/nas135/MyDocument/1+2.txt"
window.open (encodeURI (URL), "", "" "," ");

See through Debug
encodeURI (URL) = "Http://192.168.6.135/nas135/MyDocument/1%2b2.txt", but can not open server-side 1+2.txt files, do not know if it is because of the 64 machine reason? Would you please help me explain?

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.