# Codings form native UTF8 to windows1250 (iconv)

**URL:** https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515
**Category:** General
**Created:** [2 February 2019 20:17 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515 "2019-02-02T20:17:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Vladimirbuta](https://avatars.discourse-cdn.com/v4/letter/v/bb73d2/32.png) [@Vladimirbuta](https://discourse.nodered.org/u/Vladimirbuta)
#### Post date: [2 February 2019 20:17 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/1 "2019-02-02T20:17:37Z")

</div>

Hi,

I need make same changes in a text file with windows 1250 encoding. To decoding to UTF-8 I use node-red-contrib-iconv [https://flows.nodered.org/node/node-red-contrib-iconv](https://flows.nodered.org/node/node-red-contrib-iconv) and works fine, but iconv is only to decoding.

The question is how convert back to windows 1250 encoding?

---

<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: [2 February 2019 21:18 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/2 "2019-02-02T21:18:12Z")

</div>

Do you _really_ need to do that? Perhaps you could explain a bit more about what you are trying to achieve.

Most systems, including Windows, all work on Unicode now.

However, if you really want to do it, the simplest way (without other external tools), assuming you are working on Windows or another platform with PowerShell installed is to do something like the following PowerShell command via the exec node:

```auto
Get-Content -Path "path/to/your/file/filname.txt" | Out-File -FilePath "wherever/destfile.txt" -Encoding ascii

```

This will change from unicode to ascii with the current platform's default codepage.

---

<div class="post-metadata">

### Author: ![Vladimirbuta](https://avatars.discourse-cdn.com/v4/letter/v/bb73d2/32.png) [@Vladimirbuta](https://discourse.nodered.org/u/Vladimirbuta)
#### Post date: [2 February 2019 22:18 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/3 "2019-02-02T22:18:46Z")

</div>

Thank you for your reply,

yes I need it, the file is symbol table from software Step7 developed by Siemens. 🇩🇪

This flow run on raspberry.

My reason is now using external js library icon-lite

> <https://stackoverflow.com/questions/38481130/use-an-external-js-library-in-a-node-red-function>

  

> **[iconv-lite](https://www.npmjs.com/package/iconv-lite)**
>
> Convert character encodings in pure javascript.

---

<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: [3 February 2019 12:23 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/4 "2019-02-03T12:23:32Z")

</div>

> [@Vladimirbuta](#):
>
> My reason is now using external js library icon-lite

Good find, I didn't spot that with a quick search.

You can, if you wish, `require` that in your `settings.js` file under the globals section. Then in a function node, you can simply assign it to a variable `var iconv = global.get('iconv')` or whatever you called it. Then you can use it within that function node.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [3 February 2019 14:06 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/5 "2019-02-03T14:06:18Z")

</div>

> [@Vladimirbuta](#):
>
> text file with windows 1250 encoding. To decoding to UTF-8 I use node-red-contrib-iconv and works fine

It would help if you could share a text file with the original data (windows-1250 encoded). Having a look on the [encoding table](http://string-functions.com/encodingtable.aspx?encoding=1250&decoding=65001) you will see that many characters will be converted to untranslatable characters, for instance: Á,Â,Ä,Ç,É,Ë,Í,Î,Ú,Ü will be translated to �,�,�,�,�,�,�,�,�,�. In such case, you can imagine what will happen if you try to translate �,�,�,�,�,�,�,�,�,� back to windows-1250. So, my point (not sure if this is your case) is that ,many times, the encoding-decoding back to the same set will not work and this is not a fault of the supporting library.

---

<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: [3 February 2019 15:26 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/6 "2019-02-03T15:26:12Z")

</div>

Hello @Vladimirbuta  
I’m the developer of node-red-contrib-iconv and I don’t understand why can’t you do what you want to do.  
This node has the ability to encode any type of String and decode any type of Buffer.  
Could you please paste your flow or at least the text you want to encode/decode?

---

<div class="post-metadata">

### Author: ![Vladimirbuta](https://avatars.discourse-cdn.com/v4/letter/v/bb73d2/32.png) [@Vladimirbuta](https://discourse.nodered.org/u/Vladimirbuta)
#### Post date: [4 February 2019 09:01 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/7 "2019-02-04T09:01:13Z")

</div>

Hi [machadotiago](https://discourse.nodered.org/u/machadotiago),

I thought, the converter is only to decoding and for "Coding" is missing. But the the module is universal and everything works fine. Thank you 🙂

---

<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: [4 February 2019 12:13 UTC](https://discourse.nodered.org/t/codings-form-native-utf8-to-windows1250-iconv/7515/8 "2019-02-04T12:13:07Z")

</div>

Awesome! If you have any suggestion/improvement please let me know.
