1.0.1 • Published 8 years ago

utf8safe-uhex v1.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

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