简体   繁体   中英

Convert unicode to Chinese characters

Supposing I have a string of code like so:

\å\±\±\ä\¸\Š\ç\š\„\ä\º\º

How would I convert these back into Chinese characters using Javascript:

山上的人

This is so that I can actually display Chinese on my web page. Right now it comes out as å±±ä¸ç人 .

This website manages to accomplish this, however this is with PHP they don't expose.

I am not familiar with how character encoding works well at all, so I don't even know the terminology to search for a proper solution.

The string appears to be in UTF-8.

https://github.com/mathiasbynens/utf8.js is a helpful Javascript library that saves you the headache of learning the UTF-8 standard, and will decode the UTF-8 into text.

Here's a demo: https://mothereff.in/utf-8

Paste in \å\±\±\ä\¸\Š\ç\š\„\ä\º\º into the "UTF-8-encoded" textarea to decode it.

Add <meta charset="UTF-8"> inside the <head></head> tag of your HTML file so that it will display Chinese properly. Just put the Chinese characters directly in your HTML file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM