progress icon indicating copy to clipboard operation
progress copied to clipboard

Chinese Display Error, unreadable code, how ?

Open gaopengpian opened this issue 8 years ago • 5 comments

pg = Spinner('中文') pg.finish()

gaopengpian avatar Jul 04 '16 09:07 gaopengpian

Seems to work for me. Can you try this example and let me know if it works?

from progress.spinner import Spinner
import time

pg = Spinner('中文')
for i in range(20):
    time.sleep(0.1)
    pg.next()
pg.finish()

verigak avatar Sep 18 '16 18:09 verigak

I am so sorry for no reply for a long time, thanks for you reply. I have tested the code above, the error is still on. image

gaopengpian avatar Jan 23 '17 02:01 gaopengpian

This has nothing to do with the progress module. The python parser cannot parse your test.py file because it has Non-ASCII characters inside (namely '中文') and there is no encoding declared. Try adding something like this:

# -*- coding: utf-8 -*-

in the beginning of the file. Check PEP 263 (https://www.python.org/dev/peps/pep-0263/) for more info.

skalkoto avatar Jan 23 '17 10:01 skalkoto

I add the coding, but the output is unreadable code. image

gaopengpian avatar Jan 24 '17 08:01 gaopengpian

I have no experience with Windows and I don't know if your file's encoding is actually UFT-8 but if I had to guess about your problem I would say that the software is using ANSI escape characters, that from what I read here: https://en.wikipedia.org/wiki/ANSI_escape_code are not working on Windows:

Although hardware text terminals have become increasingly rare in the 21st century, the relevance of the ANSI standard persists because most terminal emulators interpret at least some of the ANSI escape sequences in the output text. One notable exception was the Win32 console component of Microsoft Windows before Windows 10 update TH2.

Maybe check this thread: http://stackoverflow.com/questions/16755142/how-to-make-win32-console-recognize-ansi-vt100-escape-sequences

skalkoto avatar Jan 25 '17 13:01 skalkoto