# Problem with string lists

**URL:** <https://forum.inductiveautomation.com/t/problem-with-string-lists/55127>\
**Category:** Ignition\
**Created:** [January 18, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127 "2022-01-18T17:46:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 5:46pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/1 "2022-01-18T17:46:39Z")

</div>

Hello,

i have a problem with lists of string:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59f15d40b83840509fb816d9572b45481e7dab80.png)

This behavior is somewhat strange… I want the letter “ì” to appear accented in the list and that’s it without any strange characters.

How can I do?

Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 18, 2022, 5:47pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/2 "2022-01-18T17:47:41Z")

</div>

Try this:

```auto
a = [u"Lunedì"]

```

Though you shouldn’t really fret about the “toString” representation of a list - you have no control over that.

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 5:49pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/3 "2022-01-18T17:49:20Z")

</div>

Already tried … But unfortunately without success:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/4107fdd83c0eaacc3c0d713628eb760793672875.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 18, 2022, 5:50pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/4 "2022-01-18T17:50:56Z")

</div>

Well, tough luck, the string representation of a list is out of your control 🤷‍♂️

Try assembling your own string representation?

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/5 "2022-01-18T17:57:13Z")

</div>

I use a list of strings as a path of variables in which I have to write a value .. The path must be correct and not with strange hexadecimal symbologies:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/1/e12c5c0f76c901234da7a01914b58fbbde7c98b7.png)

Why Ignition interprets a string in a list like this when Python normally does it correctly:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/d/8dac05a6762bd3c7d2b02488980afb69ae79415e.png)

> [@Kevin.Herron](#):
>
> Try assembling your own string representation?

How do you mean?

---

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [January 18, 2022, 5:58pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/6 "2022-01-18T17:58:41Z")

</div>

If you `print` every item in the list, you get the output you expect.

Also, import `unicode_literals` from ` __future__ ` to free yourself of prepending all your string with `u`.

```python
from __future__ import unicode_literals

a = "Lunedì"

print a, type(a)

a = ["Lunedì"]

for item in a:
    print item, type(item)

```

Output:

```python
>>> 
Lunedì <type 'unicode'>
Lunedì <type 'unicode'>

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 18, 2022, 5:58pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/7 "2022-01-18T17:58:47Z")

</div>

The _actual value_ of the string is unchanged. The string representation you get from `print()` is not, _but it should not matter to your code_, and if it does, you’re doing something wrong.

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 6:28pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/8 "2022-01-18T18:28:28Z")

</div>

This is why these hexadecimal characters are not good…

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b2e671505149663b700016e12b7f84d8e52d4fb1.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 18, 2022, 6:34pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/9 "2022-01-18T18:34:00Z")

</div>

Can you share your actual code? Unless you’re parsing _the string representation of a list_ back into a list somehow, you probably have a different problem.

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 6:38pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/10 "2022-01-18T18:38:05Z")

</div>

This is the custom method called “getTimer(id)” triggered by the valueChanged of dropdown list:

```auto
	"""
	
	paths = ["Week_Day_%s", "On_Minute_%s", "On_Hour_%s"]
	
	tags = []
	
	for path in paths:
		tags.append("[default]" + path % id)
	
	timer, minute, hour = system.tag.readBlocking(tags, 5000)
	
	timer = timer.value
	minute = minute.value
	hour = hour.value
	
	paths = ["Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"]
	
	tags = []
	
	for path in paths:
		tags.append("[default]Timers/" + path)
		
	tags.append("[default]Timers/Start/Minuti")
	tags.append("[default]Timers/Start/Ore")
	
	vals = []
	
	vals.append(utils.getBit(0, timer)) # Domenica
	vals.append(utils.getBit(1, timer)) # Lunedì
	vals.append(utils.getBit(2, timer)) # Martedì
	vals.append(utils.getBit(3, timer)) # Mercoledì
	vals.append(utils.getBit(4, timer)) # Giovedì
	vals.append(utils.getBit(5, timer)) # Venerdì
	vals.append(utils.getBit(6, timer)) # Sabato
	vals.append(minute)
	vals.append(hour)
	
	system.tag.writeBlocking(tags, vals, 5000)

```

---

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [January 18, 2022, 6:42pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/11 "2022-01-18T18:42:40Z")

</div>

Try adding the following import statement at the very top

```python
from __future__ import unicode_literals

```

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 18, 2022, 6:54pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/12 "2022-01-18T18:54:37Z")

</div>

> [@cesrom](#):
>
> `from __future__ import unicode_literals`

Yes, thanks. It works (only from project script)!

The only thing is that I can't use this import with the custom method but only from a project script:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/3787ff4175c05f2fb41d47ba836238ea27917f4f.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 18, 2022, 7:02pm UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/13 "2022-01-18T19:02:54Z")

</div>

> [@Kowa92](#):
>
> `paths = ["Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"]`

You get the same error with those string literals marked as unicode, with the `u` prefix flag?

It's a Python 2 limitation/behavior to parse unflagged string literals as ISO-8859. You can either put your logic in a project library script (in which case you should be able to use the `from __future__ ` line @cesrom suggested) _or_ you must tag your string literals as Unicode to ensure they're parsed correctly.

---

<div class="post-metadata">

**Author:** ![Kowa92](https://avatars.discourse-cdn.com/v4/letter/k/779978/32.png) [@Kowa92](https://forum.inductiveautomation.com/u/Kowa92)\
**Post date:** [January 19, 2022, 9:11am UTC](https://forum.inductiveautomation.com/t/problem-with-string-lists/55127/14 "2022-01-19T09:11:26Z")

</div>

As you said, it works either with the `from __future__ import unicode_literals` method, or with `[u"Lunedì", ...]` and also with this one that i chose:

```auto
        ...

	tags = []
	
	for path in paths:
		tags.append("[default]Timers/" + unicode(path, "utf-8"))
		
	tags.append("[default]Timers/Start/Minuti")

        ...

```

Thanks everyone for the tip! 🙂
