Which Character Encoding Is The Ipython Terminal Using?
I used to think I had this whole encoding stuff pretty figured out. I seem to be wrong because I can't explain what's happening here. What I was trying to do is to use the tabulate
Solution 1:
IPython uses OEM code page in the interactive mode like any other Python console program:
In [1]: '\u2552'ERROR - failed to write data to stream: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp850'>
Out[1]:
In [2]: !chcp
Active code page: 850
The result changes if pyreadline
is installed (it enables colors in the IPython console among other things):
In [1]: '\u2552'Out[1]: '╒'In [2]: import sys
In [3]: sys.stdout.encoding
Out[3]: 'cp850'In [4]: !chcp
Active code page: 850
Once pyreadline
has been installed, IPython's sys.displayhook
writes the result to readline's console object that uses WriteConsoleW()
Windows Unicode API that allows to print even unencodable in the current code page Unicode characters (to see them, you might need to configure a (TrueType) font such as Lucida Console in the Windows console).
Post a Comment for "Which Character Encoding Is The Ipython Terminal Using?"