Gathering detailed insights and metrics for iconv-lite
Gathering detailed insights and metrics for iconv-lite
Gathering detailed insights and metrics for iconv-lite
Gathering detailed insights and metrics for iconv-lite
Convert character encodings in pure javascript.
npm install iconv-lite
99.7
Supply Chain
99.6
Quality
75.9
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,078 Stars
283 Commits
282 Forks
62 Watching
4 Branches
35 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1.9%
17,419,240
Compared to previous day
Last week
3.8%
95,058,877
Compared to previous week
Last month
16.4%
380,433,260
Compared to previous month
Last year
20.3%
3,725,668,664
Compared to previous year
stream
module to enable Streaming API).1var iconv = require('iconv-lite'); 2 3// Convert from an encoded buffer to a js string. 4str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251'); 5 6// Convert from a js string to an encoded buffer. 7buf = iconv.encode("Sample input string", 'win1251'); 8 9// Check if encoding is supported 10iconv.encodingExists("us-ascii")
1 2// Decode stream (from binary data stream to js strings) 3http.createServer(function(req, res) { 4 var converterStream = iconv.decodeStream('win1251'); 5 req.pipe(converterStream); 6 7 converterStream.on('data', function(str) { 8 console.log(str); // Do something with decoded strings, chunk-by-chunk. 9 }); 10}); 11 12// Convert encoding streaming example 13fs.createReadStream('file-in-win1251.txt') 14 .pipe(iconv.decodeStream('win1251')) 15 .pipe(iconv.encodeStream('ucs2')) 16 .pipe(fs.createWriteStream('file-in-ucs2.txt')); 17 18// Sugar: all encode/decode streams have .collect(cb) method to accumulate data. 19http.createServer(function(req, res) { 20 req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) { 21 assert(typeof body == 'string'); 22 console.log(body); // full request body string 23 }); 24});
See all supported encodings on wiki.
Most singlebyte encodings are generated automatically from node-iconv. Thank you Ben Noordhuis and libiconv authors!
Multibyte encodings are generated from Unicode.org mappings and WHATWG Encoding Standard mappings. Thank you, respective authors!
Comparison with node-iconv module (1000x256kb, on MacBook Pro, Core i5/2.6 GHz, Node v0.12.0). Note: your results may vary, so please always check on your hardware.
operation iconv@2.1.4 iconv-lite@0.4.7
----------------------------------------------------------
encode('win1251') ~96 Mb/s ~320 Mb/s
decode('win1251') ~95 Mb/s ~246 Mb/s
stripBOM: false
in options
(f.ex. iconv.decode(buf, enc, {stripBOM: false})
).
A callback might also be given as a stripBOM
parameter - it'll be called if BOM character was actually found.addBOM: true
option.This library supports UTF-16LE, UTF-16BE and UTF-16 encodings. First two are straightforward, but UTF-16 is trying to be smart about endianness in the following ways:
defaultEncoding: 'utf-16be'
option. Strips BOM unless stripBOM: false
.addBOM: false
to override.This library supports UTF-32LE, UTF-32BE and UTF-32 encodings. Like the UTF-16 encoding above, UTF-32 defaults to UTF-32LE, but uses BOM and 'spaces heuristics' to determine input endianness.
defaultEncoding: 'utf-32be'
option. Strips BOM unless stripBOM: false
.addBOM: false
to override. (defaultEncoding: 'utf-32be'
can also be used here to change encoding.)When decoding, be sure to supply a Buffer to decode() method, otherwise bad things usually happen.
Untranslatable characters are set to � or ?. No transliteration is currently supported.
Node versions 0.10.31 and 0.11.13 are buggy, don't use them (see #65, #77).
1$ git clone git@github.com:ashtuchkin/iconv-lite.git 2$ cd iconv-lite 3$ npm install 4$ npm test 5 6$ # To view performance: 7$ node test/performance.js 8 9$ # To view test coverage: 10$ npm run coverage 11$ open coverage/lcov-report/index.html
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 5/30 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
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
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 More