scripting / Scripting-News

I'm starting to use GitHub for work on my blog. Why not? It's got good communication and collaboration tools. Why not hook it up to a blog?
121 stars 10 forks source link

Example code for iconv-lite #75

Open scripting opened 6 years ago

scripting commented 6 years ago

I'm in need of some simple example code for iconv-lite.

The functionality

I have a string which contains the text from requesting this file.

https://www.presseportal.de/rss/dienststelle_110972.rss2

I want to use iconv-lite to convert it from its charset -- ISO-8859-1 to UTF-8.

Why?

I'm seeing if I can swap out iconv for iconv-lite, to avoid problems people are having installing River5 because it requires a package that must be compiled from C. iconv-lite is all Javascript.

I wish

It were totally API compatible with iconv. That would be a thrill to have something glide into place and "just work." Alas that is not the way of Node. :-(

scripting commented 6 years ago

Here's the code I've been trying to get to work.

https://gist.github.com/scripting/3d1983a13119118173457876353ac030

Dave

scripting commented 6 years ago

I got it working.

https://gist.github.com/scripting/0b09137fdde631ccdad528dbf3a74705

The key was to ask request to return a buffer, by specifying an encoding of null.

Hopefully no one will have to wade through this problem again. ;-)