Home > Web Front-end > JS Tutorial > js unicode encoding analysis on two methods of converting data to Chinese_javascript skills

js unicode encoding analysis on two methods of converting data to Chinese_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:51:49
Original
1327 people have browsed it
Copy code The code is as follows:

var str = "\u6211\u662Funicode\u7F16\u7801";

Regarding the problem of converting such data into Chinese, there are two commonly used methods.

1. eval parsing
Copy code The code is as follows:

str = eval("'" str "'"); // "I am unicode encoding"

2. unescape parsing
Copy code The code is as follows:

str = unescape(str.replace(/\u/g, "%u")); // "I am unicode encoding"

Little knowledge points, record and share
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