I'm having trouble reading windows-1250 encoded data. I'm using http request node to download a .csv file which is encoded in windows-1250. I thought I could read it as a binary buffer and then parse the byte array to string. I tried using TextDecoder() to decode it in function node, but it gives me "ReferenceError: TextDecoder is not defined (line 1, col 19)". Am I missing an import somewhere or what am I doing wrong and how can I solve this?
I don't think we expose the base nodejs util library (and thus textdecoder) inside the function node sandbox - you can add it to the context via settings.js - see https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules
I managed to import the library as you said, thank you. Now the problem is, it says the "windows-1250" encoding is not supported. I found this and If I understand correctly I can do nothing about it other than re-compile the library?
There are libraries that will correctly do this for you. Have a look on npm. Install into
~/.node-red manually and reference in settings.js.
Why don´t you simply decode the file using node-red-contrib-iconv?
Works like a charm, thank you!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.