Home > Web Front-end > JS Tutorial > How to convert url into Chinese characters in javascript

How to convert url into Chinese characters in javascript

醉折花枝作酒筹
Release: 2023-01-07 11:44:19
Original
4047 people have browsed it

In javascript, you can use the unescape() function, decodeURIComponent() function and decodeURI() function to convert url into Chinese characters.

How to convert url into Chinese characters in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Related functions

Convert to url format Convert to Chinese characters
escape(key) unescape(key)
encodeURI(key) decodeURI(key)
encodeURIComponent(key) decodeURIComponent(key)

Introduction

The most commonly used one should be encodeURIComponent, which It is a URL encoding that converts special characters such as Chinese and Korean into UTF-8 format. Therefore, if you need to use encodeURIComponent to pass parameters to the background, you need background decoding to support UTF-8 (the encoding method in the form is the same as the encoding method of the current page).

escape does not encode 69 characters: *, ,-,.,/,@,_,0-9,a-z,A-Z.

encodeURI has 82 non-encoded characters: !, #, $, &, ', (,), *, ,,,-,.,/,:,;,=,?, @,_,~,0-9,a-z,A-Z.

encodeURIComponent has 71 unencoded characters: !, ', (,), *, -, ., _, ~, 0-9, a-z, A-Z.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to convert url into Chinese characters in javascript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template