


Instructions for using javascript URL encoding and decoding_javascript skills
In some delivery pages, GB2312 is used, while UTF8 is used in the receiving page, so the received parameters may be inconsistent with the original ones. The results are different between URLs encoded using the server-side urlEncode function and URLs encoded using the client-side JavaScript's encodeURI function.
Encoding method in javaScript:
escape() method:
Using the ISO Latin character set to encode the specified string. All spaces, punctuation marks, special characters and other non-ASCII characters will be converted into character encoding in %xx format (xx is equal to the hexadecimal number of the character's encoding in the character set table). For example, the encoding corresponding to the space character is . The unescape method is the opposite. Characters that will not be encoded by this method: @ * /
English explanation: MSDN JScript Reference: The escape method returns a string value (in Unicode format) that contains the contents of [the argument].
All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character.
For example, a space is returned as " ."
Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings.
The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set.
The unescape function returns the ASCII string for the specified hexadecimal encoding value.
encodeURI() method : Convert the URI string into an escape format string using UTF-8 encoding format. Characters that will not be encoded by this method: ! @ # $& * ( ) = : / ; ? '
English explanation: MSDN JScript Reference: The encodeURI method returns an encoded URI.
If you pass the result to decodeURI, the original string is returned.
The encodeURI method does not encode the following characters: ":", "/", ";", and "?".
Use encodeURIComponent to encode these characters . Edge Core Javascript Guide: Encodes a Uniform Resource
Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF- 8 encoding of the character
encodeURIComponent() method : Convert the URI string into an escape format string using UTF-8 encoding format. Compared with encodeURI(), this method will encode more characters, such as / and other characters. Therefore, if the string contains several parts of the URI, you cannot use this method to encode, otherwise the URL will display an error after the / character is encoded. Characters that will not be encoded by this method: ! * ( )
English explanation: MSDN JScript Reference: The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned.
Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1 /folder2 /default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a
single URI component. Mozilla Developer Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one,
two, or three escape sequences representing the UTF- 8 encoding of the character.
Therefore, for Chinese strings, if you do not want to convert the string encoding format into UTF-8 format (such as the original page and target When the charset of the page is consistent), you only need to use escape. If your page is GB2312 or other encoding, and the page that accepts parameters is UTF-8 encoded, you must use encodeURI or encodeURIComponent.
In addition, encodeURI/encodeURIComponent was introduced after javascript1.5, and escape was available in javascript1.0.
English note: The escape() method does not encode the character which is interpreted as a space on the server side as well as generated by forms with spaces in their fields.
Due to this shortcoming, you should avoid use of escape() whenever possible. The best alternative is usually encodeURIComponent().
Use of the encodeURI() method is a bit more specialized than escape() in that it encodes for URIs [REF] as opposed to the querystring,
which is part of a URL. Use this method when you need to encode a string to be used for any resource that uses URIs and needs certain characters to remain un- encoded. Note that this method does not encode the ' character, as it is a valid character within URIs.Lastly, the encodeURIComponent() method should be used in most
cases when encoding
a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included.
Note that this method
does not encode the ' character, as it is a valid character within URIs.
1. Encoding processing Function
1) encodeURI returns a result of encoding the URI string.URL is the most common URI;
2) decodeURI decodes an encoded URI string into the original string and returns it;
3) Example: Output The results are as follows: encodeStr: http://www.amigoxie.com/index.jsp?name=amigoxie decodeStr: http://www.amigoxie.com/index.jsp?name=xind
2. Numerical processing Function
1) parseInt converts the base specified by a string into an integer. The syntax format is: parseInt(numString, [radix]) The first parameter is the string to be converted, which is between 2 and 36 The value between is used to specify the base used for string conversion. Examples are as follows: The output results are as follows: The default result: 32:32;032:26;0x32:50 The result converted to binary: 32:NaN;032:0;0x32:0 The result converted to octal :32:26;032:26;0x32:0 The result of conversion to hexadecimal: 32:50;032:50;0x32:50 11001010 The result after conversion: binary: 202; hexadecimal: 285216784 octal System: 2359816; Decimal: 11001010 43abc after conversion: 43; abc43 after conversion: NaN; after abc conversion: NaN
2) parseFloat method This method converts a string into the corresponding decimal. eg. The output results are as follows: 4.11 5.1 3) isNaN method This method is used to detect whether the return value of the first two methods is non-numeric. If so, return true, otherwise, return false

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
