I want a shell that supports Unicode on Windows. PowerShell as it ships doesn’t seem to.
PowerShell V2 (Windows 7 x64):
PS C:\> powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\> python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> unicode_char=unichr(0xf12)
>>> unicode_char
u'\u0f12'
>>> print unicode_char
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\python26\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u0f12' in position 0: character maps to <undefined>
>>>
I get similar results with PowerShell ISE, even though some places around the web claim it to be Unicode supporting or whatever…
The Python Integrated Development Environment (IDLE) 2.6.2 seems to work fine:
>>> unicode_char=unichr(0xf12)
>>> print unicode_char
༒
>>>
IDLE is very slow, and I would prefer another shell, any ideas? Can I make this work in PowerShell?
The Windows console subsystem is not Unicode, but code page based. You can play around with setting the code page:
I couldn’t get (0xF12) to give the right character with that codepage. Perhaps it is available on another code page.
ISE can display Unicode and accept Unicode input, for example,
However, ISE doesn’t seem to play well with the IronPython interpreter.
Further to the point that ISE seems to handle Unicode coming from a native application via stdout: