{"name":"utf-8","version":"1.0.0","keywords":["utf-8","encode","decode","encoder","decoder","strict"],"author":{"name":"Nicolas Froidure"},"_id":"utf-8@1.0.0","maintainers":[{"name":"nfroidure","email":"nfroidure@elitwork.com"}],"homepage":"https://github.com/nfroidure/UTF8.js","bugs":{"url":"https://github.com/nfroidure/UTF8.js/issues"},"dist":{"shasum":"429c09fb1ac32cebaf565961eda48cb3f4522197","tarball":"http://registry-npm.ywwl.com/utf-8/download/utf-8-1.0.0.tgz","integrity":"sha512-jP6zNSbUze7D+UgqJyZuSl6yCtxWamRb2rY+secSxn0H7u352SHWCSraZhl6ZAF7u4WJS8aTgY6+a8wgBYtLRg==","signatures":[{"sig":"MEUCIHtlyxXFYntOOzXobxWdBTKmU1CJX2z8LaknvkxJ1b1rAiEAqGMFINZTHD/ZC+hGuN3m6AIxzxM28+VEpomcdrTDcQ0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":10003,"noattachment":false,"key":"/utf-8/-/utf-8-1.0.0.tgz"},"main":"./src/UTF8.js","_from":".","_shasum":"429c09fb1ac32cebaf565961eda48cb3f4522197","engines":{"node":">=0.10.0"},"gitHead":"f2ba4f9207957ab81e500935915c65853bfd3fe4","scripts":{"test":"node_modules/mocha/bin/mocha tests/*.mocha.js","cover":"./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/mocha/bin/_mocha -- tests/*.mocha.js -R spec -t 5000","coveralls":"./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"},"_npmUser":{"name":"nfroidure","email":"nfroidure@elitwork.com"},"repository":{"url":"http://github.com/nfroidure/UTF8.js.git","type":"git"},"_npmVersion":"2.5.1","description":"Encode/decode UTF8.","directories":{},"_nodeVersion":"0.12.0","dependencies":{"string.fromcodepoint":"^0.2.1","string.prototype.codepointat":"^0.2.0"},"preferGlobal":"false","devDependencies":{"karma":"~0.12.37","mocha":"~2.2.5","istanbul":"~0.3.16","coveralls":"~2.11.2","karma-mocha":"~0.2.0","mocha-lcov-reporter":"0.0.2","karma-chrome-launcher":"~0.2.0","karma-firefox-launcher":"~0.1.6","karma-phantomjs-launcher":"~0.2.0"},"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# utf-8\n> Encode/decode UTF8.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/utf-8/blob/main/LICENSE)\n\n\n[//]: # (::contents:start)\n\nAs you probably noticed, there is already standards ways to\n encode/decode utf-8 strings into buffers in the NodeJS\n standard library.\n\nThis library can be useful if you need to write at given buffer\n indexes or to validate utf-8 encoded buffers.\n\nOtherwise, use NodeJS standard library.\n\n## Usage\n\n```sh\nnpm install utf-8\n```\n\n### Encoding\n\nA char:\n\n```js\nimport * as UTF8 from 'utf-8';\n\nUTF8.setBytesFromCharCode('é'.charCodeAt(0));\n// [0xC3, 0xA9]\n```\n\nA string:\n\n```js\nUTF8.setBytesFromString('1.3$ ~= 1€');\n// [49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172]\n```\n\n### Decoding\n\nA char:\n\n```js\nString.fromCharCode(UTF8.getCharCode([0xc3, 0xa9]));\n// 'é'\n```\n\nA string:\n\n```js\nUTF8.getStringFromBytes([49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172]);\n// '1.3$ ~= 1€'\n```\n\n### TypedArrays are welcome\n\nAs inputs:\n\n```js\nconst bytes = new Uint8Array([\n  0xc3, 0xa9, 49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172,\n]);\n\n// The first char\nString.fromCharCode(UTF8.getCharCode(bytes));\n// é\n\n// The following string at the offset 2\nUTF8.getStringFromBytes(bytes, 2);\n// '1.3$ ~= 1€'\n```\n\nAs well as outputs :\n\n```js\nconst bytes = new Uint8Array(14);\n\n// First encoding a char\nUTF8.setBytesFromCharCode('é'.charCodeAt(0));\n\n// Then encoding a string\nUTF8.setBytesFromString('1.3$ ~= 1€', 2);\n```\n\n## UTF8 encoding detection\n\n```js\nUTF8.isNotUTF8(bytes);\n// true | false\n```\n\nThis function can prove the text contained by the given bytes is not UTF-8 (or\nbadly encoded UTF-8 string). It's not reciprocally true, especially for short\nstrings with which false positives are frequent.\n\n## Strict mode\n\nIf you try to encode an UTF8 string in an ArrayBuffer too short to contain the\ncomplete string, it will silently fail. To avoid this behavior, use the strict\nmode :\n\n```js\nUTF8.setBytesFromString('1.3$ ~= 1€', 2, null, true);\n```\n\n# Thanks\n\n- The Debian project for it's free (as freedom) russian/japanese man pages used\n  for real world files tests!\n\n[//]: # (::contents:end)\n\n# Authors\n- [Nicolas Froidure](https://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/utf-8/blob/main/LICENSE)\n","publish_time":1435253139310,"_cnpm_publish_time":1435253139310,"dist-tags":{"latest":"3.0.0"}}