utf8safe-uhex

1.0.1 • Public • Published

utf8safe-uhex

Hex-escape (\uHHHH) those UCS-2 characters that cannot be encoded as UTF-8, and the replacement character, to help you distinguish verbatim occurrences from freshly discarded data.

Usage

trom test.js:

  var utf8safe_uhex = require('utf8safe-uhex'),
    orig = "\uD83D\uDC15\u2771" + "\uDC15" + "\uD83D" + "\u2770\uD83D\uDC04",
    expect = noSpace("🐕  ❱  \\u  DC15  \\u  D83D  ❰  🐄"),
    actual = utf8safe_uhex(orig);
  expectStrictEqual(actual, expect);

License

ISC

Package Sidebar

Install

npm i utf8safe-uhex

Weekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • mk-pmb