{"name":"chardet","version":"2.2.0","homepage":"https://github.com/runk/node-chardet","description":"Character encoding detector","license":"MIT","repository":{"type":"git","url":"git+https://github.com/runk/node-chardet.git"},"bugs":{"url":"http://github.com/runk/node-chardet/issues"},"scripts":{"build":"rm -rf lib/* && tsc -p tsconfig.build.json","format":"prettier --write ./src/**/*.ts","format:check":"prettier --list-different ./src/**/*.ts","test":"npm run test:typecheck && vitest run --coverage","test:typecheck":"tsc","prepublish":"npm run build","semantic-release":"semantic-release","typecheck":"tsc"},"main":"lib/index.js","typings":"lib/index.d.ts","engine":{"node":">=4"},"directories":{"test":"test"},"devDependencies":{"@types/node":"^24.0.0","@vitest/coverage-v8":"^4.1.9","prettier":"^3.0.0","semantic-release":"^25.0.0","tsx":"^4.22.4","typescript":"^5.0.0","vitest":"^4.1.9"},"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","windows-1257","windows-1258","windows-874","TIS-620","KOI8-R"],"author":{"name":"Dmitry Shirokov","email":"deadrunk@gmail.com"},"contributors":[{"name":"@spikying"},{"name":"@wtgtybhertgeghgtwtg"},{"name":"@suisho"},{"name":"@seangarner"},{"name":"@zevanty"}],"browser":{"./lib/fs/node.js":"./lib/fs/browser.js"},"gitHead":"1a8216d75eca573972d0b11ef00fd21e965bfd08","_id":"chardet@2.2.0","_nodeVersion":"24.16.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-rddelWYNPRrXq6PtNEN2S3f6t9ILzvqaN5pVgi4kqt9jHQaXIial9PznB5iSPVlQSLNaaH22ItWz3EJtQ10+OA==","shasum":"005d664f2cbd4961888d2e2c32c5a69e59d8eec4","tarball":"http://registry-npm.ywwl.com/chardet/download/chardet-2.2.0.tgz","fileCount":39,"unpackedSize":178969,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/chardet@2.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGuB/Nu7sUA5yJEbSKdSdwXbLJkLJtUmly8LxqWaXMinAiAaafypJzfrO3FVe0ZIFmQCiIhcuEbBp4AEaRNE1iQFKg=="}],"size":25685,"noattachment":false,"key":"/chardet/-/chardet-2.2.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b96b7c9d-4a32-430b-b47b-854847ddb460"}},"maintainers":[{"name":"runk","email":"deadrunk@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chardet_2.2.0_1781920836934_0.31813462267099557"},"_hasShrinkwrap":false,"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":1781920837138,"_cnpm_publish_time":1781920837138,"dist-tags":{"latest":"2.2.0"}}