manatlan / guy

Graphics User Ynterface : a simple module for making GUI applications (with html/js) for py3 ... to target windows, linux, mac & android
Apache License 2.0
203 stars 23 forks source link

charset in <head> isn't interpreted #4

Closed inillaug closed 4 years ago

inillaug commented 4 years ago

Hello,

I put in but the character "è" appear as "è". If open the html without loading webserver the character "è" is correct.

manatlan commented 4 years ago

Hi,

It appears that you are on windows, and you was using a non-utf8 editor, like notepad ... no ?

Sorry for that, but currently, html's content can only be utf8 (and no windows-1252 or consorts) ...

Try the same thing, with a ut8's ready editor (set the file's encoding to utf8) .. and tell me

inillaug commented 4 years ago

Hello manatlan, the html file is already in UTF-8. I've opened it with "Notepad++" in Windows7. The head content is already meta-tagged as UTF-8.

meta http-equiv="Content-Type" content="text/html; charset=utf-8" meta charset="UTF-8"

manatlan commented 4 years ago

could you post me your html file ? to have a look

manatlan commented 4 years ago

I've understand ;-) You've setted your meta tag as if it was utf8 ... But, on windows, default encoding is "mbcs" (cp-1252 in europe) : so your content is windows-1252 ! try to set your meta as "Windows-1252" .. and it should work (or configure your notepad++ to encode your text content as utf8). In fact : your meta tag should be the same as the content encoding (if it differs, like you, you encounter this kind of troubble)

I close ... feel free to reopen if not

inillaug commented 4 years ago

Hello, No way. If I open the html file directly in Firefox, the viewing is correct. If I open the html file trough guy -> Firefox, the wiewing is wrong.

manatlan commented 4 years ago

Hi, glad to hear you again ...

Can you provide a version of your HTML file, so I could see the trouble, and could fix it ?

inillaug commented 4 years ago

Hi, how can I send you the file?

manatlan commented 4 years ago

you can attach a file ... here in a comment !

inillaug commented 4 years ago

below the code....

`<!DOCTYPE html>

Ciao Ciao!

Ciao Mondo!

Questa è la nostra prima pagina HTML!

`

manatlan commented 4 years ago

can your repost a comment, with the file embedded in the msg (by just dragging it from your file folder to the comment in your browser) ?

(because, with copying/pasting like this, there are a (lot of) treatment on the content, which will corrupt/correct the content)

inillaug commented 4 years ago

Here the file...

Simple.zip

manatlan commented 4 years ago

thanks ... Capture du 2020-03-16 20-38-33

Your file is well encoded (content is really utf8, and declared as utf8) It works like expected ...

here is my test

#!/usr/bin/python
# -*- coding: utf-8 -*-
import guy

class Simple(guy.Guy):
    pass

if __name__ == "__main__":
    Simple().run()

what's the trouble ? (which python version ? which os ?) test.zip

inillaug commented 4 years ago

myresult

Above my result with your python test code. The OS is WIN7 64bit Python is 3.6.8 64bit

manatlan commented 4 years ago

Strange ... and your chrome version ? (mine : Version 80.0.3987.87)

inillaug commented 4 years ago

Google Chrome Version 80.0.3987.132

manatlan commented 4 years ago

In the real world, your browser should see that the page is UT8 (according the meta declaration), and display it as ... UTF8. But in your case: it's clearly display it, as "Windows-1252" ... so it shows "è" instead of "è".

I don't think it could be a windows trouble (not a py trouble too).

The only thing: perhaps have you forced your Chrome to display all pages as "Windows-1252" ... BTW, i don't find how to set this in current chrome settings (it seems that the easy option has been removed) ... or perhaps you have a chrome extension which override defaults ?!?

I will think/search about it .. and come back later with an idea ;-)

manatlan commented 4 years ago

https://support.google.com/chrome/forum/AAAAP1KN0B02JIo6Yu7K-I/?hl=en&gpf=%23!topic%2Fchrome%2F2JIo6Yu7K-I

inillaug commented 4 years ago

If I run the code in "server mode" and I open the webpage in firefox or IE the trouble is the same. If I open the file "Simple.html" directly in firefox, IE, chrome the webpage is rendered correctly without trouble. Anyway I'll test your suggestion.

manatlan commented 4 years ago

and if you visit : https://a-starlette.glitch.me/spe what do you see ?

you should see: Capture du 2020-03-17 18-19-08

inillaug commented 4 years ago

I saw exactly wath you saw.

manatlan commented 4 years ago

So, it can't be a trouble in your browser.

Run my test ^^, in server mode, and try to point your browser to your real IP --> http://:8000 (replace "localhost" by your real IP)

inillaug commented 4 years ago

I already did this test. If I run the code in "server mode" and I open the webpage in firefox, IE, chrome the trouble is the same.

inillaug commented 4 years ago

I did all test executed before in win7 on a win10 machine with the same trouble.

manatlan commented 4 years ago

on monday, I will have access to a win10/py3.7+latest chrome ... I will have a test ... but if this was really a bug I'd already seen it

inillaug commented 4 years ago

I tested with win10/py3.7 and the trouble is the same. "Simple.html" loaded with apache shows correctly.

inillaug commented 4 years ago

The same code of Simple.html put in doc string works correctly. See the attached py file.

testmanatlanstring.zip

inillaug commented 4 years ago

The trouble is in parsing the file to string. See this code....

testmanatlanstringext.zip

manatlan commented 4 years ago

ok thanks @inillaug ! You have found the trouble ! It's my fault ... I thought that py3 known how to read a text file on "non-utf8" file system. I apply a patch soon

manatlan commented 4 years ago

Please try the newest release : https://pypi.org/project/guy/0.5.4/ it should fix this issue

thanks a lot for your work !!!

inillaug commented 4 years ago

Version 0.5.4 fixed the issue. thanks a lot for your help!!