Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jsunescape

cachelina4MIT1.0.0

Unescape JavaScript special characters

unescape, js unescape, escape sequences, special characters, unicode, decode hexidecimal, unescape browser, unescape polyfill

readme

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