{"name":"chardet","version":"2.1.0","keywords":["encoding","character","utf8","detector","chardet","icu","character detection","character encoding","language","iconv","iconv-light","UTF-8","UTF-16","UTF-32","ISO-2022-JP","ISO-2022-KR","ISO-2022-CN","Shift_JIS","Big5","EUC-JP","EUC-KR","GB18030","ISO-8859-1","ISO-8859-2","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","KOI8-R"],"author":{"name":"Dmitry Shirokov","email":"deadrunk@gmail.com"},"license":"MIT","_id":"chardet@2.1.0","maintainers":[{"name":"runk","email":"deadrunk@gmail.com"}],"contributors":[{"name":"@spikying"},{"name":"@wtgtybhertgeghgtwtg"},{"name":"@suisho"},{"name":"@seangarner"},{"name":"@zevanty"}],"homepage":"https://github.com/runk/node-chardet","bugs":{"url":"http://github.com/runk/node-chardet/issues"},"dist":{"shasum":"1007f441a1ae9f9199a4a67f6e978fb0aa9aa3fe","tarball":"http://registry-npm.ywwl.com/chardet/download/chardet-2.1.0.tgz","fileCount":39,"integrity":"sha512-bNFETTG/pM5ryzQ9Ad0lJOTa6HWD/YsScAR3EnCPZRPlQh77JocYktSHOUHelyhm8IARL+o4c4F1bP5KVOjiRA==","signatures":[{"sig":"MEUCIQDAcW7rQb4rTQA5kFYXj+YBphfp+9oKkM+NgWeSYcgHdQIgYfyiRBU21/geW8g7ewUBm2y6S7GW0O/BVyqclw5xmSQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":161783,"size":23243,"noattachment":false,"key":"/chardet/-/chardet-2.1.0.tgz"},"main":"lib/index.js","engine":{"node":">=4"},"browser":{"./lib/fs/node.js":"./lib/fs/browser.js"},"gitHead":"a1cdaca3b7f934ff876fe7a7cbb66fd2447243e4","scripts":{"test":"jest","build":"rm -rf lib/* && tsc","format":"prettier --write ./src/**/*.ts","typecheck":"tsc","prepublish":"npm run build","format:check":"prettier --list-different ./src/**/*.ts","semantic-release":"semantic-release"},"typings":"lib/index.d.ts","_npmUser":{"name":"runk","email":"deadrunk@gmail.com"},"repository":{"url":"git+https://github.com/runk/node-chardet.git","type":"git"},"_npmVersion":"10.9.2","description":"Character encoding detector","directories":{"test":"test"},"_nodeVersion":"20.18.2","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","ts-jest":"^29.0.0","ts-node":"^10.9.1","prettier":"^3.0.0","typescript":"^5.0.0","@types/jest":"^29.0.0","@types/node":"^22.0.0","semantic-release":"^24.0.0"},"_npmOperationalInternal":{"tmp":"tmp/chardet_2.1.0_1740435988288_0.11904569588026837","host":"s3://npm-registry-packages-npm-production"},"readme":"# chardet\n\n_Chardet_ is a character detection module written in pure JavaScript (TypeScript). Module uses occurrence analysis to determine the most probable encoding.\n\n- Packed size is only **22 KB**\n- Works in all environments: Node / Browser / Native\n- Works on all platforms: Linux / Mac / Windows\n- No dependencies\n- No native code / bindings\n- 100% written in TypeScript\n- Extensive code coverage\n\n## Installation\n\n```\nnpm i chardet\n```\n\n## Usage\n\nTo return the encoding with the highest confidence:\n\n```javascript\nimport chardet from 'chardet';\n\nconst encoding = chardet.detect(Buffer.from('hello there!'));\n// or\nconst encoding = await chardet.detectFile('/path/to/file');\n// or\nconst encoding = chardet.detectFileSync('/path/to/file');\n```\n\nTo return the full list of possible encodings use `analyse` method.\n\n```javascript\nimport chardet from 'chardet';\nchardet.analyse(Buffer.from('hello there!'));\n```\n\nReturned value is an array of objects sorted by confidence value in descending order\n\n```javascript\n[\n  { confidence: 90, name: 'UTF-8' },\n  { confidence: 20, name: 'windows-1252', lang: 'fr' },\n];\n```\n\nIn browser, you can use [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instead of the `Buffer`:\n\n```javascript\nimport chardet from 'chardet';\nchardet.analyse(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x6f]));\n```\n\n## Working with large data sets\n\nSometimes, when data set is huge and you want to optimize performance (with a trade off of less accuracy),\nyou can sample only the first N bytes of the buffer:\n\n```javascript\nconst encoding = await chardet.detectFile('/path/to/file', { sampleSize: 32 });\n```\n\nYou can also specify where to begin reading from in the buffer:\n\n```javascript\nconst encoding = await chardet.detectFile('/path/to/file', {\n  sampleSize: 32,\n  offset: 128,\n});\n```\n\n## Working with strings\n\nIn both Node.js and browsers, all strings in memory are represented in UTF-16 encoding. This is a fundamental aspect of the JavaScript language specification. Therefore, you cannot use plain strings directly as input for `chardet.analyse()` or `chardet.detect()`. Instead, you need the original string data in the form of a Buffer or Uint8Array.\n\nIn other words, if you receive a piece of data over the network and want to detect its encoding, use the original data payload, not its string representation. By the time you convert data to a string, it will be in UTF-16 encoding.\n\nNote on [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/TextEncoder): By default, it returns a UTF-8 encoded buffer, which means the buffer will not be in the original encoding of the string.\n\n## Supported Encodings:\n\n- UTF-8\n- UTF-16 LE\n- UTF-16 BE\n- UTF-32 LE\n- UTF-32 BE\n- ISO-2022-JP\n- ISO-2022-KR\n- ISO-2022-CN\n- Shift_JIS\n- Big5\n- EUC-JP\n- EUC-KR\n- GB18030\n- ISO-8859-1\n- ISO-8859-2\n- ISO-8859-5\n- ISO-8859-6\n- ISO-8859-7\n- ISO-8859-8\n- ISO-8859-9\n- windows-1250\n- windows-1251\n- windows-1252\n- windows-1253\n- windows-1254\n- windows-1255\n- windows-1256\n- windows-1257\n- windows-1258\n- windows-874 (TIS-620 / ISO-8859-11)\n- KOI8-R\n\nCurrently only these encodings are supported.\n\n## TypeScript?\n\nYes. Type definitions are included.\n\n### References\n\n- http://site.icu-project.org/\n- https://github.com/TypesettingTools/uchardet\n\n### TODO\n- [ ] KOI8-U for Ukrainian\n- [ ] IBM866 for DOS Cyrillic\n- [ ] macintosh and x-mac-cyrillic\n- [ ] CP949 / UHC support within the Korean recognizer\n- [ ] ISO-8859-3, ISO-8859-4\n- [ ] ISO-8859-10, ISO-8859-13\n- [ ] ISO-8859-14, ISO-8859-15, ISO-8859-16\n- [ ] DOS CP850, CP852, CP855\n","publish_time":1740435988483,"_cnpm_publish_time":1740435988483,"dist-tags":{"latest":"2.2.0"}}