# TextArea letter mix up

**URL:** <https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [March 22, 2019, 7:46am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527 "2019-03-22T07:46:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [March 22, 2019, 7:46am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/1 "2019-03-22T07:46:17Z")

</div>

Hello Inductive Team,

I’m struggling with a textarea. In a popup window a user can enter some data manually in a TextArea. Data get stored in a MS SQL server V14.0.1. If he enters e.g. a temperatur value like 8°C and it get stored int the DB all is fine. But if he want to edit those data and I read the record back from the DB and load it into the TextArea I get: 8Â°C.  
When I store (update) the record into the DB that Â get stored too.  
Any idea, how I can prevent that?  
Regards  
Mike

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 22, 2019, 10:21am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/2 "2019-03-22T10:21:12Z")

</div>

Make sure the table column is set to use a unicode or utf8 encoding.

---

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [March 22, 2019, 11:31am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/3 "2019-03-22T11:31:57Z")

</div>

The table column is set to varchar(50) and the collation to SQL\_Latin1\_General\_CP1\_CI\_AS.  
Unicode or utf8 is not selectable. What setting do I have to change?

---

<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:** [March 22, 2019, 2:16pm UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/4 "2019-03-22T14:16:58Z")

</div>

MSSQL uses `nvarchar` to store unicode data - [https://docs.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-2017](https://docs.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-2017) - you’ll need to change the column or migrate your data into a new column.

---

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [March 25, 2019, 12:15pm UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/5 "2019-03-25T12:15:16Z")

</div>

Thanks’ for the remark. I made a new column in my table as nvarchar(50) and wrote a new record to the DB into that new column. If I have a look into the DB - it is fine, if I show the record in a power table - looks good, but if I read it to a text field or area still the same problem.

---

<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:** [March 25, 2019, 3:08pm UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/6 "2019-03-25T15:08:35Z")

</div>

How are you displaying it in a text field? A direct query binding, or using a script?

---

<div class="post-metadata">

**Author:** ![mikesch73](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mikesch73](https://forum.inductiveautomation.com/u/mikesch73)\
**Post date:** [March 26, 2019, 7:09am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/7 "2019-03-26T07:09:36Z")

</div>

It’s a script.  
I found the problem, even I do not see the problem.  
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.TxtA\_Note’).text = (data.getValueAt(0,“NOTE”)) that works now.  
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.TxtA\_Note’).text = str(data.getValueAt(0,“NOTE”)) do not work.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [March 26, 2019, 7:30am UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/8 "2019-03-26T07:30:18Z")

</div>

That’s because Python makes a difference between `str` and `unicode` objects. What you get back from your DB is a `unicode` object, but if you cast it to `str`, the result will use the environment encoding, so possibly lose information.

There’s no reason to cast anything here, so just leave out the cast.

---

<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:** [March 26, 2019, 2:34pm UTC](https://forum.inductiveautomation.com/t/textarea-letter-mix-up/23527/9 "2019-03-26T14:34:59Z")

</div>

Leave out the cast, or use the built in `unicode()` to cast, instead of `str()`, so that you don’t lose non-ASCII characters.
