# Special character encoding /Utf8 problem

**URL:** <https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120>\
**Category:** General\
**Created:** [22 November 2018 14:15 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120 "2018-11-22T14:15:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![deedos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/deedos/32/236_2.png) [@deedos](https://discourse.nodered.org/u/deedos)\
**Post date:** [22 November 2018 14:15 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/1 "2018-11-22T14:15:57Z")

</div>

Hi,

I need to use special characters (from portuguese, pt-br) like ç, ã and so forth, in a flow, specifically to write to a xml file. At the debug window on node-red, the characters looks all correct but when writing to disk, the special charcaters get messed.

The xml is being writtern as this:

```auto
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><video><title/><keywords>palavras,chave</keywords><description>descri��o</description></video>

```

the charset of the file is iso-8859-1 as returned by the "file" command

```
file -bi undefined.xml 
text/xml; charset=iso-8859-1

```

the flow is below (change your file path - msg.filename - at the "format-xml" node)

```auto
[{"id":"160cecbf.c27973","type":"inject","z":"4a0b25ab.85b84c","name":"","topic":"","payload":"joão","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":1300,"wires":[["c942a09.f98966"]]},{"id":"c942a09.f98966","type":"function","z":"4a0b25ab.85b84c","name":"format xml","func":"var title = msg.payload ;\n\nmsg.payload = \n{ \n \"video\": {\n \"title\" : title,\n \"keywords\" : \"palavras,chave\",\n \"description\": \"descrição\"\n\n }\n}\n \nmsg.filename = \"YOUR_PATH\" + title + \".xml\" ;\n\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":1300,"wires":[["181f599b.af4696"]]},{"id":"181f599b.af4696","type":"xml","z":"4a0b25ab.85b84c","name":"","property":"payload","attr":"","chr":"","x":630,"y":1300,"wires":[["4c14ec7f.c0e354"]]},{"id":"4c14ec7f.c0e354","type":"file","z":"4a0b25ab.85b84c","name":"","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":790,"y":1300,"wires":[["68469962.d91c58"]]},{"id":"68469962.d91c58","type":"debug","z":"4a0b25ab.85b84c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":970,"y":1300,"wires":[]}]

```

how can I have the special characters in the written file ?

Many thanks in advance

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [22 November 2018 14:34 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/2 "2018-11-22T14:34:40Z")

</div>

please read [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and the edit the code you posted

---

<div class="post-metadata">

**Author:** ![deedos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/deedos/32/236_2.png) [@deedos](https://discourse.nodered.org/u/deedos)\
**Post date:** [22 November 2018 15:19 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/3 "2018-11-22T15:19:06Z")

</div>

done @ukmoose, thanks for pointing that out

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [22 November 2018 16:36 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/4 "2018-11-22T16:36:43Z")

</div>

Taking your flow and using MacOS it outputs the special characters.

```auto
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><video><title>joão</title><keywords>palavras,chave</keywords><description>descrição</description></video>

```

What are you using to read the file?

---

<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:** [22 November 2018 16:52 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/5 "2018-11-22T16:52:30Z")

</div>

I tested your flow and got the special characters correctly spelled/printed/displayed in the file name as well as in the xml content (opened with notepad++). Also all looks good in Node-RED debug.

My setup is Node-REd running in Windows10.

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/791ce381aae3016b0c28152fbf0087440b797b35.png)

![r-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1822020a44627db2458b0ae9a8d37b6c3d17e0fc.png)

---

<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:** [22 November 2018 17:08 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/6 "2018-11-22T17:08:15Z")

</div>

I wonder why your file has been generated with such forward slash at the end of the `title tag`.

```auto
<title/>

```

Or perhaps this issue was introduced when you copy and pasted the excerpt to this post thread ?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [22 November 2018 17:12 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/7 "2018-11-22T17:12:21Z")

</div>

I'm guessing its because the flow that generated that didn't include a title hence `undefined.xml`

---

<div class="post-metadata">

**Author:** ![deedos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/deedos/32/236_2.png) [@deedos](https://discourse.nodered.org/u/deedos)\
**Post date:** [22 November 2018 17:17 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/8 "2018-11-22T17:17:09Z")

</div>

Hi @Andrei , the title tag is like that cause the title value was somehow broken due to the special character. My file was named undefined.xml ..  
I forgot to mention node-red is writing to and installed in a debian 9 machine. The strange thing is that now I get the joão.xml written ok and as @ukmoose mentioned, the xmls looks messy depending on the way I read it. The one I pasted in this thread was a "cat" command from the linux terminal. If I open with gedit on a Ubuntu machine, It reads correctly.  
The last issue now is that I'm appending that xml to a http form to send to a API. the api is reading it wrongly as well. Anything I could do or the problem is only on the API side ? Thanks you both for helping me out  
cheers

---

<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:** [22 November 2018 17:36 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/9 "2018-11-22T17:36:27Z")

</div>

> [@deedos](#):
>
> I'm appending that xml to a http form to send to a API. the api is reading it wrongly as well

I guess the better place to look now is on how you build the http request. I guess you are using an `http request` node in your flow, right ? Can you share this part of this config (removing any tokens / passwords) ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 November 2018 20:36 UTC](https://discourse.nodered.org/t/special-character-encoding-utf8-problem/5120/10 "2018-11-22T20:36:30Z")

</div>

> [@deedos](#):
>
> The one I pasted in this thread was a "cat" command from the linux terminal. If I open with gedit on a Ubuntu machine, It reads correctly.

That may be down to whether the application you are using to view it is using a font containing those characters.
