Convert from/to encodings with iconv-lite only
See original GitHub issueTake this example:
mystr = new Buffer("base64 string with ISO-8859-1 encoding goes here", "base64").toString();
buffer = new Buffer(buffer, "ISO-8859-1"); <--- this will fail as Buffer doesn't support that encoding
buffer = iconv.decode(buffer, "ISO-8859-1");
buffer = iconv.encode(buffer, "utf8").toString("utf8");
This code should be able to convert from a ISO-8859-1 (or any other encoding) string to UTF8, but it will fail because of the second line.
Can that be done using iconv-lite?
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to use the iconv-lite.encodingExists function in ... - Snyk
Hack to make iconv load the encodings module, otherwise jest crashes. Compare // https://github.com/sidorares/node-mysql2/issues/489 require('iconv-lite').
Read more >Use iconv to change character string encoding
First we will demonstrate converting the three common encoding (ASCII, CP1252, and ISO-8559-1) to/from UTF-8, then using iconv.convert() to convert between ...
Read more >iconv-lite not decoding everything properly, even though I'm ...
Does C++ support converting between character encodings other than UTF-8, UTF-16, and UTF-32? 1 · html textarea using specific character set · 0....
Read more >iconv-lite - npm
Convert character encodings in pure javascript.. Latest version: 0.6.3, last published: a year ago. Start using iconv-lite in your project ...
Read more >iconv - Manual - PHP
iconv — Convert a string from one character encoding to another ... returns an empty string (or you'll get a notice but only...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re inadvertently converting the
chunk
to string by doingbuffer += chunk
. You should keep it as a buffer, something like this:Yes, sure.
iconv.decode(buf, encoding)
takes binary data and decodes it into a JS string. So, what you’re need here is: