1.0.0 • Published 1 year ago
jsunescape v1.0.0
jsUnescape
Unescape special characters encoded with JavaScript escape sequences
Install
npm install --save jsunescape
Motivation
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.
Usage
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'
License
MIT © Catalina Espinoza
1.0.0
1 year ago