# Bad encoding from script

**URL:** <https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221>\
**Category:** Ignition\
**Created:** [October 24, 2014, 10:42am UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221 "2014-10-24T10:42:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serhii](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Serhii](https://forum.inductiveautomation.com/u/Serhii)\
**Post date:** [October 24, 2014, 10:42am UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221/1 "2014-10-24T10:42:58Z")

</div>

Hello!  
Using Ignition 7.7.1 x64  
I have “Tree view”:  
[screenshot.su/show.php?img=e4bd8 … 534667.jpg](http://screenshot.su/show.php?img=e4bd84ba30daf7d966356d2780534667.jpg)  
As you can see, some of “path” has bad encoding. This rows with bad encoding was inserted by script `dataset = event.source.parent.getComponent('Tree View')
tags = system.tag.browseTagsSimple("Vent/", "ASC")
for tag in tags:
	if tag.name.find("P-") != -1:
		newRow = ["Приточные установки/",tag.name,"default","color(255,255,255,255)","color(0,0,0,255)","","","","default","color(250,214,138,255)","color(0,0,0,255)","",""]
		dataset.data = system.dataset.addRow(dataset.data, newRow) `  
Another rows with good encoding was created directly by hands.  
How can i fix this issue?

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [October 24, 2014, 2:11pm UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221/2 "2014-10-24T14:11:52Z")

</div>

Try adding u before the string.

```auto
newRow = [u"Приточные установки/",tag.name,"default","color(255,255,255,255)","color(0,0,0,255)","","","","default","color(250,214,138,255)","color(0,0,0,255)","",""]
```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 24, 2014, 5:38pm UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221/3 "2014-10-24T17:38:10Z")

</div>

[quote=“jpark”]Try adding u before the string.

```auto
newRow = [u"Приточные установки/",tag.name,"default","color(255,255,255,255)","color(0,0,0,255)","","","","default","color(250,214,138,255)","color(0,0,0,255)","",""]
```

I think I tried that before while helping someone else out. Had the same results. I think it has to do with the string sitting inside a list.

I have another idea in mind, but I’ll need some time to sort it out.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 24, 2014, 6:30pm UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221/4 "2014-10-24T18:30:21Z")

</div>

I’ll retract what I posted. I don’t know what I was missing from my previous tries, but Jae’s solution will work. 😃

Mine looks a bit kludgy, but it also works. Now I’m wondering if it had something to do with the previous Jython version… ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

[code]import codecs

…

newRow = [codecs.utf\_8\_decode(“Приточные установки/”)[0],tag.name,“default”,“color(255,255,255,255)”,“color(0,0,0,255)”,"","","",“default”,“color(250,214,138,255)”,“color(0,0,0,255)”,"",""]

[/code]

---

<div class="post-metadata">

**Author:** ![Serhii](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Serhii](https://forum.inductiveautomation.com/u/Serhii)\
**Post date:** [October 27, 2014, 11:02am UTC](https://forum.inductiveautomation.com/t/bad-encoding-from-script/9221/5 "2014-10-27T11:02:41Z")

</div>

[quote=“jpark”]Try adding u before the string.

```auto
newRow = [u"Приточные установки/",tag.name,"default","color(255,255,255,255)","color(0,0,0,255)","","","","default","color(250,214,138,255)","color(0,0,0,255)","",""]
```

Thanks! ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")
