# Trouble with the 7.4.1 version about the string conversion

**URL:** <https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252>\
**Category:** Ignition\
**Created:** [April 5, 2012, 2:25pm UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252 "2012-04-05T14:25:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 5, 2012, 2:25pm UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252/1 "2012-04-05T14:25:13Z")

</div>

I have some trouble with the 7.4.1 version about the string conversion in many scripts afetr upgrading my server  
My scripts was ok in 7.3.3 b570

I have some error in 7.4.1 when :

- str() is executed on a string variable
- when sql query return characters such as ‘ê’ or ‘é’  
see the following example executed in the script playground:

```auto
def htmlInfoPae(id_pae):
	import app.commun
	import system

	table = system.db.runPrepQuery("SELECT * from VUE_PAE_TERRITOIRE where id_pae=?",[id_pae],dbfrontal)
	html = "<HTML><HEAD><TITLE>PAE : " + str(id_pae) + "</TITLE></HEAD><BODY>"

	if len(table)==1:
		html = html + "PAE : " + str(id_pae) + "<BR>¤"
		[b]html = html + "Commune : " + table[0]["COMMUNE"] + "<BR>"[/b]
		html = html + "</BODY></HTML>"	
	else:
		html = html + "PAE : " + str(id_pae) + "<BR><BR>Pas de détail ???"+ "</BODY></HTML>"	
	return (html)

import sys
#print sys.getdefaultencoding()
#print "¤" + " téêst " + "¤"
print htmlInfoPae(1)
```

the error message (for the line in bold)

![]()

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/06a30bca0e3f46d93a691549488b90419298c4a3.png)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [April 5, 2012, 4:01pm UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252/2 "2012-04-05T16:01:33Z")

</div>

The problem is you are trying to print the ascii characters out and some characters are unicode. You can do the following for the print statement:`print htmlInfoPae(1).encode('ascii', 'replace')`which will put ? for every unknown ascii character. If you save it to a file or something it should be fine.

We did upgrade Jython in 7.4 which is why it may have worked in 7.3.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 5, 2012, 8:13pm UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252/3 "2012-04-05T20:13:32Z")

</div>

thank for your help  
I found a solution with these actions on my 7.3.3 scripts for a compatibility in 7.4.1

suppress the str() cast on string variable (it generated an exception if string containt non ascii character)  
replace instruction like `"Arrêt " + table[0] with [b]u[/b]"Arrêt " + table[0]`

🙂

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 5, 2012, 8:17pm UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252/4 "2012-04-05T20:17:46Z")

</div>

replace :

```auto
"Arrêt " + table[0]
```

with :

```auto
u"Arrêt " + table[0]
```

prefix all the non-ascii or extended ascii const string with u"" !

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [April 6, 2012, 12:06am UTC](https://forum.inductiveautomation.com/t/trouble-with-the-7-4-1-version-about-the-string-conversion/4252/5 "2012-04-06T00:06:14Z")

</div>

Thanks for posting the solution!
