[BUG-1902]Web Dev encoding error


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 image
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?

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

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.

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.

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 (2.6 KB)
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:

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…


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.

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

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

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:

As in this example:

	html = u'''<!DOCTYPE html>
	<html><head><meta charset="UTF-8"></head>
	return {'html': html, 'contentType': 'text/html;charset=utf-8'}

Which works correctly on Windows: