简体   繁体   中英

Decode Encoded String

I have a box that looks like this. I am trying to put it into a string like this

var t = "🟩"

but whenever I try to do that, it automatically gets encoded into something that looks like this 🟩

Here is my code:

<div id="green" style="display: none;">🟩</div>

Should Be

<div id="green" style="display: none;">🟩</div>

How do I decode it? (This code is being uploaded to chrome://extensions if that helps. Thats why its changing I think)

Add <meta charset="UTF-8"> to the head tag.

 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <div id="green"></div> </body> </html>

Also why have you set display to none?

The charset attribute specifies the character encoding for the HTML document.

The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!

<!DOCTYPE html>
 <html>

  <head>
   <meta charset="UTF-8">
  </head>

  <body>
    ...       
  </body>

 </html>

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