Character encoding auto-detection in JavaScript (port of python's chardet)
Installations
npm install jschardet
Developer Guide
Typescript
Yes
Module System
N/A
Min. Node Version
>=0.1.90
Node Version
20.17.0
NPM Version
10.8.2
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (98.58%)
Shell (0.72%)
CSS (0.58%)
HTML (0.12%)
Developer
aadsm
Download Statistics
Total Downloads
107,493,439
Last Day
39,712
Last Week
214,535
Last Month
969,942
Last Year
19,347,372
GitHub Statistics
724 Stars
158 Commits
97 Forks
16 Watching
2 Branches
15 Contributors
Bundle Size
325.41 kB
Minified
115.47 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.1.4
Package Id
jschardet@3.1.4
Unpacked Size
1.26 MB
Size
435.32 kB
File Count
57
NPM Version
10.8.2
Node Version
20.17.0
Publised On
30 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
107,493,439
Last day
-10.6%
39,712
Compared to previous day
Last week
-9.9%
214,535
Compared to previous week
Last month
9.1%
969,942
Compared to previous month
Last year
19.2%
19,347,372
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
JsChardet
Port of python's chardet (https://github.com/chardet/chardet).
License
LGPL
How To Use It
Node
npm install jschardet
var jschardet = require("jschardet")
// "à Ãà çã" in UTF-8
jschardet.detect("\xc3\xa0\xc3\xad\xc3\xa0\xc3\xa7\xc3\xa3")
// { encoding: "UTF-8", confidence: 0.9690625 }
// "次常用國å—標準å—體表" in Big5
jschardet.detect("\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed")
// { encoding: "Big5", confidence: 0.99 }
// Martin Kühl
// jschardet.detectAll("\x3c\x73\x74\x72\x69\x6e\x67\x3e\x4d\x61\x72\x74\x69\x6e\x20\x4b\xfc\x68\x6c\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e")
// [
// {encoding: "windows-1252", confidence: 0.95},
// {encoding: "ISO-8859-2", confidence: 0.8796300205763055},
// {encoding: "SHIFT_JIS", confidence: 0.01}
// ]
Browser
Copy and include jschardet.min.js in your web page.
This library is also available in cdnjs at https://cdnjs.cloudflare.com/ajax/libs/jschardet/1.4.1/jschardet.min.js
Options
1// See all information related to the confidence levels of each encoding. 2// This is useful to see why you're not getting the expected encoding. 3jschardet.enableDebug(); 4 5// Default minimum accepted confidence level is 0.20 but sometimes this is not 6// enough, specially when dealing with files mostly with numbers. 7// To change this to 0 to always get something or any other value that can 8// work for you. 9jschardet.detect(str, { minimumThreshold: 0 }); 10 11// Lock down which encodings to detect, can be useful in situations jschardet 12// is giving a higher probability to encodings that you never use. 13jschardet.detect(str, { detectEncodings: ["UTF-8", "windows-1252"] });
Supported Charsets
- Big5, GB2312/GB18030, EUC-TW, HZ-GB-2312, and ISO-2022-CN (Traditional and Simplified Chinese)
- EUC-JP, SHIFT_JIS, and ISO-2022-JP (Japanese)
- EUC-KR and ISO-2022-KR (Korean)
- KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, and windows-1251 (Russian)
- ISO-8859-2 and windows-1250 (Hungarian)
- ISO-8859-5 and windows-1251 (Bulgarian)
- windows-1252
- ISO-8859-7 and windows-1253 (Greek)
- ISO-8859-8 and windows-1255 (Visual and Logical Hebrew)
- TIS-620 (Thai)
- UTF-32 BE, LE, 3412-ordered, or 2143-ordered (with a BOM)
- UTF-16 BE or LE (with a BOM)
- UTF-8 (with or without a BOM)
- ASCII
Technical Information
I haven't been able to create tests to correctly detect:
- ISO-2022-CN
- windows-1250 in Hungarian
- windows-1251 in Bulgarian
- windows-1253 in Greek
- EUC-CN
Development
Use npm run dist
to update the distribution files. They're available at https://github.com/aadsm/jschardet/tree/master/dist.
Authors
Ported from python to JavaScript by António Afonso (https://github.com/aadsm/jschardet)
Transformed into an npm package by Markus Ast (https://github.com/brainafk)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: GNU Lesser General Public License v2.1: LICENSE:0
Reason
7 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/aadsm/jschardet/build.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/aadsm/jschardet/build.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-release.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/aadsm/jschardet/github-release.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/aadsm/jschardet/npm-publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/aadsm/jschardet/npm-publish.yml/main?enable=pin
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 2 out of 2 npmCommand dependencies pinned
Reason
Found 3/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/github-release.yml:1
- Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to jschardet
iconv-jschardet
Convert/auto-detection Character encodings in JavaScript ( iconv-lite, jschardet )
jschardet-eastasia
East Asia character(Chinese,Janpanse,Korean) encoding auto-detection in JavaScript (port of python's chardet)
jschardet-french
Character encoding auto-detection in JavaScript (port of python's chardet)
jschardet-cli
A cli wrapper for jschardet.