Home > Web Front-end > JS Tutorial > JavaScript unicode and GBK2312 (Chinese) encoding conversion method_Basic knowledge

JavaScript unicode and GBK2312 (Chinese) encoding conversion method_Basic knowledge

WBOY
Release: 2016-05-16 17:15:17
Original
1656 people have browsed it

Copy code The code is as follows:

var GB2312UnicodeConverter = {
ToUnicode: function (str ) {
                                                                                      use using with using using use using using      out out out out out out of ’s ’ ‐ to ‐ return unescape( str.replace(/\u/gi, '%u'));
}
};

var str = 'Shanghai', unicode;
document.write(str '
');unicode = GB2312UnicodeConverter.ToUnicode(str);

document.write(' Convert Chinese characters to Unicode code: 'unicode '

');
document.write('Convert Unicode code to Chinese characters:' GB2312UnicodeConverter.ToGB2312(unicode));


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