{"name":"utf-8","version":"0.1.0","keywords":["command","events"],"author":{"name":"Nicolas Froidure"},"_id":"utf-8@0.1.0","maintainers":[{"name":"nfroidure","email":"nfroidure@elitwork.com"}],"bugs":{"url":"https://github.com/nfroidure/UTF8/issues"},"dist":{"shasum":"992bfb5f7606b51437c5eaab9325a38376f43e4b","tarball":"http://registry-npm.ywwl.com/utf-8/download/utf-8-0.1.0.tgz","integrity":"sha512-a74+QoQgHtnj4KZZk3XGk1keaGHJ/phhUkw8BeS6Zk9kYciSW0bux+kTOqi1CsNQwK0MEViuhjmpJ/djiF04eg==","signatures":[{"sig":"MEYCIQDjCCrieijhYGtmQvU8yzs+/l2zE6ZkAUOGfuA5TS2IDQIhAPFlTBGH2MopQ44ifAnk6/d0eYYMUiYDbVf1ecs9XPeT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":4922,"noattachment":false,"key":"/utf-8/-/utf-8-0.1.0.tgz"},"main":"./src/UTF8.js","_from":".","engines":{"node":"*"},"scripts":{"test":"karma start karma.conf.js --single-run && karma start karma-global.conf.js --single-run"},"_npmUser":{"name":"nfroidure","email":"nfroidure@elitwork.com"},"repository":{"url":"http://github.com/nfroidure/UTF8.git","type":"git"},"_npmVersion":"1.3.5","description":"Encode/decode UTF8.","directories":{},"dependencies":{},"preferGlobal":"false","devDependencies":{"karma":"~0.10.1","karma-mocha":"*","karma-requirejs":"*","karma-firefox-launcher":"~0.1","karma-slimerjs-launcher":"0.1.2"},"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":1380545476205,"_cnpm_publish_time":1380545476205,"dist-tags":{"latest":"3.0.0"}}