0

How I can convert a HTML entity to unicode?

like: — to \u2014 or better:

const msg = 'i am &mdash lucky' // convert to i am \u2014 lucky

or is there any way to tell babel do it on compile time?!!


Edit

  • Don't offer DOM to do this, I need it for both client and server side.
  • And I don't want to replace with —, I want \u2014.
  • https://stackoverflow.com/questions/2808368/decode-html-entities-in-javascript – epascarello Oct 04 '17 at 16:55
  • @epascarello Thanks, but this is not what I want. I need a library or any function do it for all HTML entities. and not to char, to \u... –  Oct 04 '17 at 18:05

0 Answers0