Closed lj1029 closed 3 weeks ago
Hi @lj1029 you can change to below to encode as UTF-8, otherwise printing the Chinese characters will throw Python error UnicodeEncodeError: 'ascii' codec can't encode character u'\u554a' in position 16: ordinal not in range(128)
print(json_f.encode('utf-8'))
Hi , I also encounter the same problem. And it seems that add encode(utf-8) doesn't works
This picture shows the output of the code before it stuck
the origin code is as following
Inaddition I have config the env, so the console can output chinese as utf-8
Oh @yytuwefds it works for me on macOS. Without encode() I get error. With encode() it's ok. Can you share the log file at tagui/src/tagui_py? There is a log file of the real error from Python.
Thanks for response. I don't know where to find logs before. Here is the log file. It seems that it's using gbk to read Chi characters in python? I'using V6.110.0 edition in the release named TagUI_Windows.zip. Is it possible to change the config?
solved. windows python default use gbk in python. modify 83 line in tagui_py.py as tagui_input = open('tagui_py/tagui_py.in','r', encoding='utf-8') in this way, encode is also not needed to prevent such problem
Hi @kensoh , @yytuwefds Thank you for your response. I have tried modify 83 line in tagui_py.py, it works and won't stuck at py_step. But when I printing the result, I have to encode('utf8').decode('gbk'), to prevent getting garbled text.
py begin
print('你好') //garbled
print('你好').encode('utf8').decode('gbk')
py finish
echo `py_result`
My script works fine with English text and numbers, but it gets stuck at the py_step when I use Chinese characters. The script is as follows:
Could someone please help me understand why this is happening and how I can resolve it? Your assistance is greatly appreciated.