Agony5757/mahjong

Unicode problem

Closed this issue · 1 comments

Environment: Windows 10, Anaconda, Python 3.9

import pymahjong as pm
env = pm.SingleAgentMahjongEnv()
env.reset()
env.render()

Error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\envs\py39\lib\site-packages\pymahjong\env_pymahjong.py", line 402, in render
    print(self.env.t.players[0].to_string())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte

Seems need to fix the function "to_string", also for other objects, such as pm.Table.get_result().to_string()

zyr17 commented

I faced the same issue and solved the problem by adding the following lines in CMakeLists.txt:23, then run pip install ..

if (MSVC)
    add_compile_options(/execution-charset:utf-8)
endif()

If you have installed the build toolchain, you can try it and see if it works.