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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:15:171671browse

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));


Statement:
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