# \[BUG-1902\]Web Dev encoding error

**URL:** <https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656>\
**Category:** Ignition\
**Tags:** scripting, ignition80\
**Created:** [February 21, 2021, 2:49am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656 "2021-02-21T02:49:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [February 21, 2021, 2:49am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/1 "2021-02-21T02:49:11Z")

</div>

Hi,

I want to use Chinese in web pages,but they are not displayed correctly.  
I tried use “u”,before string,and they showed another error. ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/08cb983c6540e43d1b1c20b21069754f94730ac9.png) ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05feb677b34d62530358370111f3552ec671c4bf.png)  
The HTTP Method is doGet.  
Ignition 8.1.2.  
I tried linux,windows,they have the same result.  
How to fix it?  
Does it support UTF-8?

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [February 22, 2021, 3:34am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/2 "2021-02-22T03:34:19Z")

</div>

I have encountered this problem in all scripts. it looks like a bug in jython.

---

<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:** [February 22, 2021, 1:20pm UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/3 "2021-02-22T13:20:44Z")

</div>

Not a bug. The `u'xyz'`’ syntax is necessary if the string constant contains any unicode. The latter display in the browser is a browser problem I think, or a failure to deliver a content-type that specifies UTF8.

---

<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:** [February 22, 2021, 5:01pm UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/4 "2021-02-22T17:01:53Z")

</div>

Return a `contentType` key in your dictionary as well; try `text/html;charset=UTF-8`. By default the `html` return key will set the content-type to `text/html`, with no explicit charset - and if you aren’t returning a full HTML declaration (see strict mode vs quirks mode) and a meta-charset header, the browser has no way to assume the encoding and has to ‘guess’ - which generally means it will use the OS default charset.

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [February 24, 2021, 7:44am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/5 "2021-02-24T07:44:01Z")

</div>

In firefox,script without ‘u’,I set the browser charset to Unicode,and it runs well.  
That is weird…  
Here is the file.  
Added meta charset=“utf-8”.  
[index.html](https://forum.inductiveautomation.com/uploads/short-url/2NMxEvuW7e95LPt7bafKYSfDrix.html) (2.6 KB)  
But,  
This file runs well in Web Dev(Default encode).  
I copy text to script, it runs error,unless set browser charset manually.  
It can’t work with ‘u’,Chinese word will be replaced by ?.  
Part of script:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/f/ff1fd7d1f83efd9088a2de7029a077db551fd3f6.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:** [February 24, 2021, 4:50pm UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/6 "2021-02-24T16:50:17Z")

</div>

There’s a bug in Wevdev I just noticed. We’re parsing the provided HTML string with ISO-8859-1, regardless of content type specified. We’ll need to fix the HTML encoding on our end - in the meantime you could probably work around it by manually writing your content to the servlet response object…

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [February 25, 2021, 12:51am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/7 "2021-02-25T00:51:42Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [March 8, 2021, 6:44am UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/8 "2021-03-08T06:44:14Z")

</div>

Excuse me.Is there a schedule?  
When will this bug be fixed?And does it will be fixed in 8.1.x?  
More infomation:  
In Web Dev ,function(system.util.jsonEncode) will break the encoding.  
I noticed that today.

---

<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 8, 2021, 5:48pm UTC](https://forum.inductiveautomation.com/t/bug-1902-web-dev-encoding-error/43656/9 "2021-03-08T17:48:44Z")

</div>

> [@nideyijuyidong](#):
>
> Is there a schedule?  
> When will this bug be fixed?

No, no schedule. It's on our list to be fixed, and could be picked up at any time.

> [@nideyijuyidong](#):
>
> And does it will be fixed in 8.1.x?

Yes, it will be fixed in a future 8.1.x update.

> [@nideyijuyidong](#):
>
> In Web Dev ,function(system.util.jsonEncode) will break the encoding.

This would be a different issue, unrelated to what's happening in Webdev, but I don't think it's the `jsonEncode` function that's the problem.

In the meantime, you can workaround the issue by adding this line before you return your HTML body:  
`request["servletResponse"].setCharacterEncoding("UTF-8")`

As in this example:

```python
	html = u'''<!DOCTYPE html>
	<html><head><meta charset="UTF-8"></head>
	<body>
	組知画性底増江切的賞匿得価令。導者春道教将棚講厚個渡育触抗止
	</body>
	</html>'''
	request["servletResponse"].setCharacterEncoding("UTF-8")
	return {'html': html, 'contentType': 'text/html;charset=utf-8'}

```

Which works correctly on Windows:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/99be2e8ddb77ae17952efeed268098cd49ecfa0f.png)
