Unescape special characters encoded with JavaScript escape sequences
npm install --save jsunescape
Since major browsers are planning to drop the unescape function in Javascript. This package replicates the original unescape functionality found in V8 to ensure backwards comptaibility.
jsunescape
supports:
- JavaScript escape sequences described in the unescape MDN page such as %XX and %uXXXX (where X represents one hexadecimal digit) with the character that has the hexadecimal value XX/XXXX. If the escape sequence is not a valid escape sequence (for example, if % is followed by one or no hex digit), it is left as-is.
const jsUnescape = require('jsunescape');
console.log(jsUnescape('%u0107'));
// 'ć'
console.log(jsUnescape('%E4%F6%FC'));
// 'äöü'
console.log(jsUnescape('%E4"'));
// 'ä'
console.log(jsUnescape(encodeURIComponent('räksmörgås')));
//'räksmörgås'
MIT © Catalina Espinoza