# Read windows-1250 encoded data

**URL:** <https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265>\
**Category:** General\
**Created:** [21 April 2020 20:40 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265 "2020-04-21T20:40:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dyce](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dyce/32/19592_2.png) [@Dyce](https://discourse.nodered.org/u/Dyce)\
**Post date:** [21 April 2020 20:40 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/1 "2020-04-21T20:40:36Z")

</div>

Hello,  
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?

Dyce

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [21 April 2020 21:57 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/2 "2020-04-21T21:57:34Z")

</div>

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](https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules)

---

<div class="post-metadata">

**Author:** ![Dyce](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dyce/32/19592_2.png) [@Dyce](https://discourse.nodered.org/u/Dyce)\
**Post date:** [21 April 2020 22:15 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/3 "2020-04-21T22:15:21Z")

</div>

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](https://nodejs.org/api/util.html#util_encodings_supported_by_default_with_full_icu_data) and If I understand correctly I can do nothing about it other than re-compile the library?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [21 April 2020 23:06 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/4 "2020-04-21T23:06:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![machadotiago](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/machadotiago/32/23776_2.png) [@machadotiago](https://discourse.nodered.org/u/machadotiago)\
**Post date:** [21 April 2020 23:28 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/5 "2020-04-21T23:28:11Z")

</div>

Why don´t you simply decode the file using [node-red-contrib-iconv](https://flows.nodered.org/node/node-red-contrib-iconv)?

---

<div class="post-metadata">

**Author:** ![Dyce](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dyce/32/19592_2.png) [@Dyce](https://discourse.nodered.org/u/Dyce)\
**Post date:** [22 April 2020 09:57 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/6 "2020-04-22T09:57:08Z")

</div>

Works like a charm, thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 May 2020 09:57 UTC](https://discourse.nodered.org/t/read-windows-1250-encoded-data/25265/7 "2020-05-06T09:57:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
