unescapeUnicode.js 379 B

12345678910111213141516
  1. var toString = require('../lang/toString');
  2. /**
  3. * Unescape unicode char sequences
  4. */
  5. function unescapeUnicode(str){
  6. str = toString(str);
  7. return str.replace(/\\u[0-9a-f]{4}/g, function(ch){
  8. var code = parseInt(ch.slice(2), 16);
  9. return String.fromCharCode(code);
  10. });
  11. }
  12. module.exports = unescapeUnicode;