how do you print chinese with sublime in mac? (not in sublimerepl)
If run print(‘中文’) pressing cmd + b, it will report UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position
I created a python.sublime-biuld file, but it did not work (it works in win32)
{
“cmd”: ["/usr/local/bin/python3", “-u”, “$file”],
“file_regex”: “^[ ]File "(…?)”, line ([0-9]*)",
“selector”: “source.python”,
“encoding”: “cp936”
}
Let sublime print chinese in mac python3
William
#1
0 Likes
William
#3
the default one will call python2 in mac, so I create a new one to call python3 for st3. In order to print Chinese, I add "encoding: cp936"to it.
0 Likes
FichteFoll
#4
Then add this line to the build system and remove the encoding line:
"env": {"PYTHONIOENCODING": "utf-8"},
It will cause Python to output utf-8-encoded bytes which ST will, by default, interpret correctly, unless you override the encoding.
2 Likes