Js unicode encoding

Explain a wide variety of online, talk very deeply, but since I did not read, finally I found a log Ruan Yifeng Gangster:

http://www.ruanyifeng.com/blog/2014/12/unicode.html

Deep in a very good

A method Chinese to further attach a unicode:

function charToUnicode(char) {
  const res = escape(char).toLocaleLowerCase().replace(/%u/gi, '\\u')
  return res.replace(/%7b/gi, '{').replace(/%7d/gi, '}').replace(/%3a/gi, ':').replace(/%2c/gi, ',').replace(/%27/gi, '\'').replace(/%22/gi, '"').replace(/%5b/gi, '{').replace(/%5d/gi, ']').replace(/%3D/gi, '=').replace(/%20/gi, ' ').replace(/%3E/gi, '>').replace(/%3C/gi, '<').replace(/%3F/gi, '?').replace(/%5c/gi, '\\')
}

This method may not be common for a number of symbols (characters over substantially planar), which was converted to bytes does not exceed three UTF-8 encoding, several methods are used in relatively easy to use

Guess you like

Origin www.cnblogs.com/sue7/p/11693997.html