https://github.com/neocotic/escape-unicode
Node.js library to escape Unicode
https://github.com/neocotic/escape-unicode
converter escape javascript nodejs unicode
Last synced: 6 months ago
JSON representation
Node.js library to escape Unicode
- Host: GitHub
- URL: https://github.com/neocotic/escape-unicode
- Owner: neocotic
- License: mit
- Created: 2018-01-25T11:16:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T22:22:22.000Z (almost 7 years ago)
- Last Synced: 2025-04-05T05:54:48.739Z (6 months ago)
- Topics: converter, escape, javascript, nodejs, unicode
- Language: JavaScript
- Size: 52.7 KB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# escape-unicode
[](https://travis-ci.org/neocotic/escape-unicode)
[](https://codecov.io/gh/neocotic/escape-unicode)
[](https://david-dm.org/neocotic/escape-unicode?type=dev)
[](https://github.com/neocotic/escape-unicode/blob/master/LICENSE.md)
[](https://www.npmjs.com/package/escape-unicode)[escape-unicode](https://github.com/neocotic/escape-unicode) is a [Node.js](https://nodejs.org) library that can
convert Unicode characters into their corresponding Unicode escapes ("\uxxxx" notation).* [Install](#install)
* [API](#api)
* [Bugs](#bugs)
* [Contributors](#contributors)
* [License](#license)## Install
Install using `npm`:
``` bash
$ npm install --save escape-unicode
```You'll need to have at least [Node.js](https://nodejs.org) 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
``` javascript
const escapeUnicode = require('escape-unicode');escapeUnicode('♥');
//=> "\\u2665"
escapeUnicode('I ♥ Unicode!');
//=> "\\u0049\\u0020\\u2665\\u0020\\u0055\\u006e\\u0069\\u0063\\u006f\\u0064\\u0065\\u0021"
escapeUnicode('I ♥ Unicode!', 2, 3);
//=> "\\u2665"
```## Bugs
If you have any problems with this library or would like to see changes currently in development you can do so
[here](https://github.com/neocotic/escape-unicode/issues).## Contributors
If you want to contribute, you're a legend! Information on how you can do so can be found in
[CONTRIBUTING.md](https://github.com/neocotic/escape-unicode/blob/master/CONTRIBUTING.md). We want your suggestions and
pull requests!A list of contributors can be found in [AUTHORS.md](https://github.com/neocotic/escape-unicode/blob/master/AUTHORS.md).
## License
Copyright © 2018 Alasdair Mercer
See [LICENSE.md](https://github.com/neocotic/escape-unicode/raw/master/LICENSE.md) for more information on our MIT
license.