UTF-8 decode error

zeuwas
Posts: 7
Joined: 07.12.2023 12:05

UTF-8 decode error

Post 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
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: UTF-8 decode error

Post by main Alexey »

attach the file here.
i will see how Cud shows error for it.
zeuwas
Posts: 7
Joined: 07.12.2023 12:05

Re: UTF-8 decode error

Post by zeuwas »

thank you!!!
Attachments
Export_A1_Table.py111.py
(678 Bytes) Downloaded 35 times
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: UTF-8 decode error

Post 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 -*-
zeuwas
Posts: 7
Joined: 07.12.2023 12:05

Re: UTF-8 decode error

Post by zeuwas »

After removing the comment on line 9, the file opened smoothly
The comment section is in Chinese
zeuwas
Posts: 7
Joined: 07.12.2023 12:05

Re: UTF-8 decode error

Post 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)
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: UTF-8 decode error

Post by main Alexey »

so file 1st line comment is wrong. it must be removed/changed. Cud works ok.
zeuwas
Posts: 7
Joined: 07.12.2023 12:05

Re: UTF-8 decode error

Post by zeuwas »

Thank you for helping me find the problem!!!
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Re: UTF-8 decode error

Post 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.
zeuwas
Posts: 7
Joined: 07.12.2023 12:05

Re: UTF-8 decode error

Post by zeuwas »

Thank you very much for correcting the program
Post Reply