I have a python file like
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
print('娴嬭瘯')
and print like this
锟斤拷锟斤拷
what OS / Version of script are you using? works ok on OSX with 3.4.0, quick thing just to check, have a look at your file encoding settings for atom, playing with this and also changing the encoding on the bottom right of the editor caused some really weird behaviour for me.
OS: WIN10
script Version: 3.4.0
My atom file encoding setting and bottom right encoding are both utf-8
It works ok in windows cmd, but not work well in script
@LD00000 I came across the same problem. For me, it looks like atom-script on Windows uses cp1252 (Windows 1252) encoding by default instead of utf-8 (the default encoding may depend on your locale and platform).
As a work-around you can specify the encoding as utf-8 in your code for the system out and error streams:
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
print ('娴嬭瘯')
so much thanks @dbolton
so much thanks @dbolton
I solved this problem by adding an environment varibale
PYTHONIOENCODING=utf-8
You can press Ctrl+Alt+Shift+O to add it.
Most helpful comment
@LD00000 I came across the same problem. For me, it looks like atom-script on Windows uses cp1252 (Windows 1252) encoding by default instead of utf-8 (the default encoding may depend on your locale and platform).
As a work-around you can specify the encoding as utf-8 in your code for the system out and error streams: