escape-unicode
escape-unicode is a Node.js library that can
convert Unicode characters into their corresponding Unicode escapes ("\uxxxx" notation).
Install
Install using npm
:
$ npm install --save escape-unicode
You'll need to have at least Node.js 8 or newer.
API
escapeUnicode(input[, start][, end])
Converts all characters within input
to Unicode escapes.
Optionally, a start
index can be provided to begin conversion at a specific location within input
. If start
is not
specified, null
, or negative, the conversion will begin at the start of input
.
Similarly, an end
index can be provided to stop conversion at a specific location within input
. If end
is not
specified, null
, or negative, the conversion will stop at the end of input
.
Examples
const escapeUnicode = require('escape-unicode');
escapeUnicode('♥');
escapeUnicode('I ♥ Unicode!');
escapeUnicode('I ♥ Unicode!', 2, 3);
Bugs
If you have any problems with this library or would like to see changes currently in development you can do so
here.
Contributors
If you want to contribute, you're a legend! Information on how you can do so can be found in
CONTRIBUTING.md. We want your suggestions and
pull requests!
A list of contributors can be found in AUTHORS.md.
License
Copyright © 2018 Alasdair Mercer
See LICENSE.md for more information on our MIT
license.