# Spanish Character Issue

**URL:** <https://forum.inductiveautomation.com/t/spanish-character-issue/103025>\
**Category:** Ignition\
**Created:** [February 28, 2025, 3:21am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025 "2025-02-28T03:21:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharmaaman3](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sharmaaman3](https://forum.inductiveautomation.com/u/sharmaaman3)\
**Post date:** [February 28, 2025, 3:21am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/1 "2025-02-28T03:21:10Z")

</div>

i am using this script in script console for handling spanish character but not working  
def transform(value):  
try:  
corrected\_text = value.encode('iso-8859-1').decode('utf-8')  
except Exception as e:  
corrected\_text = value  
return corrected\_text  
value = "testÃ±"  
result = transform(value)  
print(result) but its working in online python compiler , not working in ignition

---

<div class="post-metadata">

**Author:** ![Louis\_Whitburn](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@Louis\_Whitburn](https://forum.inductiveautomation.com/u/Louis_Whitburn)\
**Post date:** [February 28, 2025, 4:07am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/2 "2025-02-28T04:07:30Z")

</div>

Hello

Python relies on whitespace / indentation for scope which makes your provided code hard to read. When you make a post you can click on the 'cog wheel' settings icon and select 'preformatted text' which makes it a lot easier to read, e.g. see below.

```python
def transform(value):
	try:
		corrected_text = value.encode('iso-8859-1').decode('utf-8')
	except Exception as e:
		corrected_text = value
	return corrected_text

value = "testÃ±"
result = transform(value)
print(result)

```

Without seeing an example of where this transform is actually used I can't be much help sorry but I think you might be being caught out with the fact that Python in Ignition is Python 2, not Python 3. Your 'online python compiler' is probably running Python 3. There were many changes between them, but one change was how unicode strings are handled. The 'Python 2' way of handling unicode is described here: [https://docs.python.org/2/howto/unicode.html](https://docs.python.org/2/howto/unicode.html)

For example, if I run the below code in Ignition (in the script console)

```python
def transform(value):
	try:
		corrected_text = value.encode('iso-8859-1').decode('utf-8')
	except Exception as e:
		corrected_text = value
	return corrected_text

value = u"testÃ±"
result = transform(value)
print(result)

```

I get `testñ`. The change I made is adding the `u` to `value = "testÃ±"` to make `value = u"testÃ±"`

Hopefully this points you in the right direction

---

<div class="post-metadata">

**Author:** ![sharmaaman3](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sharmaaman3](https://forum.inductiveautomation.com/u/sharmaaman3)\
**Post date:** [February 28, 2025, 4:23am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/3 "2025-02-28T04:23:30Z")

</div>

but when i am going to doing through this way in flex repeater component binding transform  
response = system.net.httpGet(url = str(url),headerValues = headerValues)  
dict = system.util.jsonDecode(response)  
for i in dict['value']:  
message\_Content\_old = (system.util.jsonDecode(i['attachments'][0]  
['content'])['body'][3]['facts'][3]['value'])  
val = u'{}'.format(message\_Content\_old)  
message\_Content = val.encode('iso-8859-1').decode('utf-8') not working

---

<div class="post-metadata">

**Author:** ![Louis\_Whitburn](https://avatars.discourse-cdn.com/v4/letter/l/8baadc/32.png) [@Louis\_Whitburn](https://forum.inductiveautomation.com/u/Louis_Whitburn)\
**Post date:** [February 28, 2025, 6:00am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/4 "2025-02-28T06:00:40Z")

</div>

The `u` can only be prepended to string literals and has to go before the quotes. All it does is change the type of the string literal from being a string to a Unicode type. The code you have is just prepending a 'u' to the string.  
I might have lead you astray with that comment, it was more to draw your attention to how Python 2 handles strings differently to Python 3, if so my apologies for that.  
The actual solution to your problem is likely going to involve seeing exactly what bytes have been returned and figuring out how to go from there. I was able to get the following working

```python
def transform(value):
    corrected_text = value.decode('utf-8').encode('iso-8859-1')
    print(type(corrected_text))
    return corrected_text

value = "\xC3\x83\xC2\xB1"
print(value)
print(type(value))
print(transform(value))

```

which prints

```python
Ã±
<type 'str'>
<type 'str'>
ñ

```

But it assumes that the 'ñ' you get from your API endpoint is C3 83 C2 B1 (a UTF-8 `Ã±`). I don't know for sure if that's the case though.

---

<div class="post-metadata">

**Author:** ![sharmaaman3](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sharmaaman3](https://forum.inductiveautomation.com/u/sharmaaman3)\
**Post date:** [February 28, 2025, 9:42am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/5 "2025-02-28T09:42:32Z")

</div>

the thing is that, i am having customized keyboard in a view where spanish character is also there taking example  
if value:  
text = 'Ñ'  
else:  
text = 'ñ'  
return text.decode('utf-8'). i am getting it correctly on label text of keyboard symbol . after that send this spanish symbol value to session params text2.getting this value into another view properly on label. and there is button which is used for post this data on teams channel  
response2 = system.net.httpPost(url=contact, contentType="Application/Json", postData=json.dumps(webhookSkeleton))  
through this way.

i am getting proper symbol on teams channel.  
but when i use this into flex repeater for instances then i am having problem.showing wrong data Ã±.  
using this on flex repeater instances  
response = system.net.httpGet(url = str(url),headerValues = headerValues)

dict = system.util.jsonDecode(response)  
for i in dict['value']:   
message\_Content = (system.util.jsonDecode(i['attachments'][0]['content'])['body'][3]['facts'][3]['value']), this message content i needed to show in flex reapeater instance but i am getting wrong display value

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [February 28, 2025, 10:04am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/6 "2025-02-28T10:04:24Z")

</div>

Maybe this can help you

> [@UTF-8 special characters "ñ" from Transform Script](https://forum.inductiveautomation.com/t/utf-8-special-characters-n-from-transform-script/91004):
>
> Hi! I aplied a transform script to a table to subsitute header values for others with special uTF-8 characters, def transform(self, value, quality, timestamp): new\_headers = [ "Equipos de PCI", "Instalacion electrica", "Señalización PCI", "Iluminación emergencia", "Salidas y vías evac.", "Señalización evacuación y", "Señalización riesgo elect.", "Caída de personas mismo nivel", "Escalas fijas", "Escaleras portátiles de mano", …

> [@UTF-8 special characters "ñ" from Transform Script](https://forum.inductiveautomation.com/t/utf-8-special-characters-n-from-transform-script/91004/2):
>
> You have used non-ASCII characters in jython string constants that do not support them. Use unicode string constants instead, using the u"Mañana" syntax. That lower-cause u before the first quote tells jython to handle the unicode characters correctly. [https://docs.python.org/2.7/reference/lexical\_analysis.html#strings](https://docs.python.org/2.7/reference/lexical_analysis.html#strings)

by @pturmel

---

<div class="post-metadata">

**Author:** ![sharmaaman3](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sharmaaman3](https://forum.inductiveautomation.com/u/sharmaaman3)\
**Post date:** [February 28, 2025, 12:47pm UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/7 "2025-02-28T12:47:19Z")

</div>

How to apply u literal before to make readable form for this  
message\_Content = (system.util.jsonDecode(i['attachments'][0]['content'])['body'][3]['facts'][3]['value'])

I am not getting it properly if i uses its value in script console as a string and applying u literal before it works fine but here how can i transform into u literal form

Any idea

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [February 28, 2025, 12:51pm UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/8 "2025-02-28T12:51:44Z")

</div>

Maybe

```python
message_Content = unicode(system.util.jsonDecode(i['attachments'][0]['content'])['body'][3]['facts'][3]['value'])

```

or

```python
message_Content = u"{}".format(system.util.jsonDecode(i['attachments'][0]['content'])['body'][3]['facts'][3]['value'])

```

---

<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:** [February 28, 2025, 1:27pm UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/9 "2025-02-28T13:27:25Z")

</div>

What version of Ignition are you using?

Similar issues reported in kinds of embedded views in Perspective were fixed recently, e.g. [[IGN-5692] Tagpaths with åäö not found in Embedded Veiw - #20 by PGriffith](https://forum.inductiveautomation.com/t/ign-5692-tagpaths-with-aao-not-found-in-embedded-veiw/56999/20)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 28, 2025, 7:35pm UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/10 "2025-02-28T19:35:12Z")

</div>

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). You can then edit each of your posts to correct them. Thanks.

---

<div class="post-metadata">

**Author:** ![sharmaaman3](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sharmaaman3](https://forum.inductiveautomation.com/u/sharmaaman3)\
**Post date:** [March 2, 2025, 7:32am UTC](https://forum.inductiveautomation.com/t/spanish-character-issue/103025/11 "2025-03-02T07:32:37Z")

</div>

in ignition i have one view and one view params Details where i am passing value is below:

(`<div style="max-height: 300pxpx; max-width: 500px; border: 0px solid black; border-radius: 0px; background-color: white; padding: 5px;"><h3>testing the code</h3><p><strong>notification</strong></p><p>Sent feb. 28, 10:36 a.Â m.</p><table style= "border-width: 0px; border-spacing: 0px; border-style: none; border-collapse: collapse; display: block; overflow: hidden; box-sizing: border-box;"><tbody><tr><td>Department</td><td>dt123 car</td></tr><tr><td>Station</td><td>805000</td></tr><tr><td>Requested</td><td>TEST</td></tr><tr><td>Details</td><td>amÃÂº</td></tr></tbody></table></div>`)  
and take markdown component and on source i put params binding and take one transform script is

```python
from HTMLParser import HTMLParser
		
	class HTMLCleaner(HTMLParser):
	    container = ""
	    key = ""
	    count = 0
	    def handle_data(self, data):
	    	if data == "Requested":
	    		self.key = "found"
	    	if self.key == "found":
	    		self.count += 1
	    	if self.count == 1 or self.count == 3:
	    		data += ": "
	    		self.container += data
	    	if self.count == 2 or self.count == 4:
	    		data += "<br>"
	    		self.container += data
	    	return self.container
	
	h = HTMLCleaner()
	h.feed(value)
	v=h.container
	return v

```

i tried this also but not working `return v.encode('latin1').decode('utf-8')`  
but i am getting data is below:  
Requested: TEST  
Details: amÃÂº

Its wrong i need correct data which is required correct data is amú.  
amÃÂº is wrong display . please help and guide me
