Skip to content

cachelina/jsunescape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published