Page 1 of 2

UTF-8 decode error

Posted: 07.12.2023 12:18
by zeuwas
When opening a file with file code cp936, an error will be reported
The file must contain Chinese characters

error UTF-8 decode error

Re: UTF-8 decode error

Posted: 07.12.2023 13:12
by main Alexey
attach the file here.
i will see how Cud shows error for it.

Re: UTF-8 decode error

Posted: 08.12.2023 09:27
by zeuwas
thank you!!!

Re: UTF-8 decode error

Posted: 08.12.2023 09:34
by main Alexey
this file has broken UTF8 text in the line 9. see how Sublime Text shows this line 9 when i force UTF8 (menu File / Reopen with encoding):

Code: Select all

from tkinter import ttk  #????һ?????׵?
so Cud error-message is good.
file 1st line:
# -*- coding: utf-8 -*-

Re: UTF-8 decode error

Posted: 08.12.2023 10:13
by zeuwas
After removing the comment on line 9, the file opened smoothly
The comment section is in Chinese

Re: UTF-8 decode error

Posted: 08.12.2023 10:23
by zeuwas
Delete the first line, the file opens smoothly
file 1st line:
# -*- coding: utf-8 -*-

Cud uses uft-8 encoding to open the file, and the actual encoding of the file is cp936(GBK)

Re: UTF-8 decode error

Posted: 08.12.2023 10:38
by main Alexey
so file 1st line comment is wrong. it must be removed/changed. Cud works ok.

Re: UTF-8 decode error

Posted: 08.12.2023 10:44
by zeuwas
Thank you for helping me find the problem!!!

Re: UTF-8 decode error

Posted: 08.12.2023 12:06
by main Alexey
i found that Cud has a bug here!! it cannot reload broken utf8 text as cp1252, so it cannot load your file at all. fix made. now Cud auto-reloads your file as cp1252.

Re: UTF-8 decode error

Posted: 08.12.2023 14:16
by zeuwas
Thank you very much for correcting the program