


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

假设您有一个想要通过网络传输的二进制图像文件。您很惊讶对方没有正确接收该文件-该文件只是包含奇怪的字符!嗯,您似乎试图以原始位和字节格式发送文件,而所使用的媒体是为流文本而设计的。避免此类问题的解决方法是什么?答案是Base64编码。在本文中,我将向您展示如何使用Python对二进制图像进行编码和解码。该程序被说明为一个独立的本地程序,但您可以将该概念应用于不同的应用程序,例如将编码图像从移动设备发送到服务器以及许多其他应用程序。什么是Base64?在深入了解本文之前,让我们先定义一下Base6

如何解决Java开发中的URL解码异常在Java开发中,我们经常会遇到需要解码URL的情况。然而,由于不同的编码方式或者不规范的URL字符串,有时候会出现URL解码异常的情况。本文将介绍一些常见的URL解码异常以及对应的解决方法。一、URL解码异常的产生原因编码方式不匹配:URL中的特殊字符需要进行URL编码,即将其转换为以%开头的十六进制值。解码时,需要使

在现代计算机编程中,C语言是一种非常常用的编程语言之一。尽管C语言本身并不直接支持中文编码和解码,但我们可以使用一些技术和库来实现这一功能。本文将介绍如何在C语言编程软件中实现中文编码和解码。首先,要实现中文编码和解码,我们需要了解中文编码的基本概念。目前,最常用的中文编码方案是Unicode编码。Unicode编码为每个字符分配了一个唯一的数字值,以便在计

Python3.x中使用urllib.parse.quote()函数对URL进行编码在网络应用开发中,经常会遇到需要对URL进行编码的情况,这是由于URL中允许的字符有限,而我们需要传递的参数可能包含了特殊字符。Python中的urllib.parse模块提供了quote()函数,可以对URL中的非法字符进行编码,使之成为合法的URL字符串。本文将通过代

Python3.x中如何使用urllib.parse.urlencode()函数对参数进行编码在进行网络编程或者进行HTTP请求时,往往需要对URL中的参数进行编码。而Python中的urllib模块提供了方便的urlencode()函数来进行URL参数的编码。本文将介绍如何在Python3.x中使用urllib.parse.urlencode()函

pin码是一种安全措施,用于保护个人信息和设备的安全。然而,有时候我们可能会忘记PIN码或需要解除PIN码。本文将讨论一些解除PIN码的方法。首先,如果您忘记了设备的PIN码,可以考虑使用设备提供的重置选项。例如,对于手机或平板电脑,可以尝试通过输入多次错误的PIN码来触发重置选项。具体的方法可能会因设备而异,您可以查询设备的用户手册或在网上查找具体的重置步

使用PHP中的urlencode()函数对URL进行编码的具体代码示例如下:<?php//定义要编码的URL$url="https://www.example.com/search?q=一个中文查询";//对URL进行编码$encodedUrl=urlencode($url);echo"编码前

Eclipse中文乱码困扰?试试这些解决方案,需要具体代码示例一、背景介绍随着计算机技术的不断发展,中文在软件开发中扮演着越来越重要的角色。然而,很多开发者在使用Eclipse进行中文开发时会遇到乱码问题,影响了工作效率。那么,本文将介绍一些常见的乱码问题,并给出相应的解决方案及代码示例,帮助读者解决Eclipse中文乱码问题。二、常见乱码问题及解决方案文件


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

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.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
