Home Web Front-end JS Tutorial Application instructions of encode and decode in js_javascript skills

Application instructions of encode and decode in js_javascript skills

May 16, 2016 pm 05:48 PM
decode encode

encodeURIComponent

Encodes a text string into a valid component of a Uniform Resource Identifier (URI).

encodeURIComponent(encodedURIString)

The required encodedURIString parameter represents an encoded URI component.

Description
The encodeURIComponent method returns an encoded URI. If you pass the encoding result to decodeURIComponent, the original string will be returned. Because the encodeURIComponent method encodes all characters, please note that if the string represents a path, such as /folder1/folder2/default.html, the slashes in it will also be encoded. As a result, the encoding result will be invalid when sent as a request to the web server. If the string contains more than one URI component, use the encodeURI method to encode it.

escape method
Returns an encoded String object that can be read on all computers.

function escape(charString : String) : String
Parameters
charString
Required. Any String object or text to encode.
Remarks
The escape method returns a string value (Unicode format) containing the contents of charstring. All spaces, punctuation, accents, and any other non-ASCII characters are replaced with the %xx encoding, where xx is equal to the hexadecimal number representing the character. For example, spaces are returned as " ".

Characters with character values ​​greater than 255 are stored in %uxxxx format.

Note that the escape method cannot be used to encode Uniform Resource Identifiers (URIs). To encode it, use the encodeURI and encodeURIComponent methods.
Requires
Version 1

See
encodeURI method | encodeURIComponent method | String object | Method

Applies to: Global object

The encodeURI method
returns a string encoded as a valid Uniform Resource Identifier (URI).

function encodeURI(URIString : String) : String
Parameters
URIString
Required. A string representing the encoded URI.
Remarks
The encodeURI method returns an encoded URI. If the encoding result is passed to decodeURI, the original string will be returned. encodeURI does not encode the following characters: ":", "/", ";", and "?".请使用 encodeURIComponent 对这些字符进行编码。

要求
版本 5.5

请参见
decodeURI 方法 | decodeURIComponent 方法

适用于:Global 对象

encodeURIComponent 方法
返回编码为统一资源标识符 (URI) 的有效组件的字符串。

function encodeURIComponent(encodedURIString : String) : String
参数
encodedURIString
必选。表示编码 URI 组件的字符串。
备注
encodeURIComponent 方法返回一个已编码的 URI。如果将编码结果传递给 decodeURIComponent,则将返回初始的字符串。因为 encodeURIComponent 方法将对所有字符编码,请注意,如果该字符串代表一个路径,例如 /folder1/folder2/default.html,则其中的斜杠也将被编码,这样,当该字符串作为请求发送到 Web 服务器时它将是无效的。如果字符串中包含多个 URI 组件,请使用 encodeURI 方法进行编码。

要求
版本 5.5

请参见
decodeURI 方法 | decodeURIComponent 方法

适用于:Global 对象

方法
从用 escape 方法编码的 String 对象中返回已解码的字符串。

function (charString : String) : String
参数
charString
必选。要解码的 String 对象或文本。
备注
方法返回一个包含 charstring 内容的字符串值。所有以 %xx 十六进制形式编码的字符都用 ASCII 字符集当中等效的字符代替。

以 %uxxxx 格式(Unicode 字符)编码的字符用十六进制编码 xxxx 的 Unicode 字符代替。

注意 方法不应用于解码“统一资源标识符”(URI)。请改用 decodeURI 和 decodeURIComponent 方法。
要求
版本 1

请参见
decodeURI 方法 | decodeURIComponent 方法 | escape 方法 | String 对象

适用于:Global 对象

decodeURI 方法
返回一个已编码的统一资源标识符 (URI) 的非编码形式。

function decodeURI(URIstring : String) : String
参数
URIstring
必选。表示编码 URI 的字符串。
备注
使用 decodeURI 方法代替已经过时的 方法。

decodeURI 方法返回一个字符串值。

如果 URIString 无效,将发生 URIError。

要求
版本 5.5

请参见
decodeURIComponent 方法 | encodeURI 方法

适用于:Global 对象

decodeURIComponent 方法
返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。

function decodeURIComponent(encodedURIString : String) : String
必选的 encodedURIString 参数是一个表示已编码的 URI 组件的值。

备注
URIComponent 是一个完整的 URI 的一部分。

如果 encodedURIString 无效,则将产生 URIError。

要求
版本 5.5

请参见
decodeURI 方法 | encodeURI 方法

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Advanced usage and skill sharing of Oracle DECODE function Advanced usage and skill sharing of Oracle DECODE function Mar 08, 2024 am 10:30 AM

The DECODE function in Oracle database is a very commonly used function, which can select among a set of values ​​based on the result value of an expression. The syntax of the DECODE function is as follows: DECODE(expression, search_value1, result1, search_value2, result2,..., default_result) where expression is the expression to be compared, s

Oracle DECODE function detailed explanation and usage examples Oracle DECODE function detailed explanation and usage examples Mar 08, 2024 pm 03:51 PM

The DECODE function in Oracle is a conditional expression that is often used to return different results based on different conditions in query statements. This article will introduce the syntax, usage and sample code of the DECODE function in detail. 1. DECODE function syntax DECODE(expr,search1,result1[,search2,result2,...,default]) expr: the expression or field to be compared. search1,

Basic usage analysis of DECODE function in Oracle Basic usage analysis of DECODE function in Oracle Mar 07, 2024 pm 04:09 PM

Analysis of the basic usage of the DECODE function in Oracle In the Oracle database, the DECODE function is a very commonly used function, used to implement logical judgment and numerical replacement similar to multi-layer if-else statements. The basic syntax of the DECODE function is as follows: DECODE(expr,search1,result1,search2,result2,...,default_result) where the parameter meanings are as follows: expr

CES 2022: Schlage launches Encode Plus Deadbolt with Apple Home Key functionality CES 2022: Schlage launches Encode Plus Deadbolt with Apple Home Key functionality May 23, 2023 pm 06:55 PM

One of the Wallet features introduced in iOS 15 is support for the Home button, which will allow users to add a HomeKit door lock-compatible digital key to the Wallet app on iPhone and Apple Watch. With this system, users can quickly unlock their home using NFC connectivity simply by holding their device close to the lock. Schlage today launched the Schlage Encode Plus Smart WiFi Deadbolt, the first smart lock in North America to support Apple’s Home Key system. EncodePlus operates as a traditional "HomeKit" deadbolt and works over Wi-Fi, eliminating the need for a separate

Advanced skills and case studies on DECODE function in Oracle Advanced skills and case studies on DECODE function in Oracle Mar 07, 2024 pm 05:48 PM

The DECODE function in Oracle is a very powerful and commonly used function, used to implement logical judgment and value replacement in data query and processing. This article will explore advanced techniques and application cases of the DECODE function, and give specific code examples. 1. Introduction to DECODE function The DECODE function is a conditional expression function in Oracle database, which is used to implement logical judgment and value replacement similar to if-then-else. The syntax is as follows: DECODE(expr,

Detailed explanation and application scenarios of Oracle DECODE function examples Detailed explanation and application scenarios of Oracle DECODE function examples Mar 07, 2024 pm 12:51 PM

Oracle database is a popular relational database management system that provides a wealth of functions and tools to handle complex data operations. Among them, the DECODE function is one of the most commonly used functions, which can convert and process data according to specified conditions. This article will introduce Oracle's DECODE function in detail, including its syntax structure, functional features, and practical application scenarios, and provide specific code examples. 1. The syntax structure of the DECODE function The syntax structure of the DECODE function is as follows: D

Practical application guide and best practices for Oracle DECODE function Practical application guide and best practices for Oracle DECODE function Mar 07, 2024 pm 01:09 PM

The DECODE function in Oracle database is a very commonly used function, which can return different results based on conditional values. In actual data processing, the DECODE function can help us perform operations such as data conversion, conditional judgment, and result return. This article will introduce the usage of the DECODE function, provide practical application guidelines and best practices, and provide specific code examples. 1. Introduction to DECODE function The basic syntax of DECODE function is: DECODE(expression,

Oracle DECODE function example analysis and application scenarios Oracle DECODE function example analysis and application scenarios Mar 08, 2024 am 11:24 AM

The OracleDECODE function is a very commonly used conditional expression function. Its main function is to convert the result of the expression according to the specified conditions and return the corresponding value. The syntax of the DECODE function is as follows: DECODE(expr,search1,result1,search2,result2,...,default_result) where expr is the expression that needs to be judged, search1, search2...

See all articles