Right solution to unicode error?

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Nov 8 15:06:42 CET 2012

On 8 November 2012 00:44, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
> On 7 November 2012 23:51, Andrew Berg <bahamutzero8825 at gmail.com> wrote:
>> On 2012.11.07 17:27, Oscar Benjamin wrote:
>>> Are you using cmd.exe (standard Windows terminal)? If so, it does not
>>> support unicode
>> Actually, it does. Code page 65001 is UTF-8. I know that doesn't help
>> the OP since Python versions below 3.3 don't support cp65001, but I
>> think it's important to point out that the Windows command line system
>> (it is not unique to cmd) does in fact support Unicode.
> I have tried to use code page 65001 and it didn't work for me even if
> I did use a version of Python (possibly 3.3 alpha) that claimed to
> support it.

I stand corrected. I've just checked and codepage 65001 does work in
cmd.exe (on this machine):

O:\>Q:\tools\Python33\python -c print('abc\u2013def')
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "Q:\tools\Python33\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in
position 3: character maps to

O:\>chcp 65001
Active code page: 65001

O:\>Q:\tools\Python33\python -c print('abc\u2013def')

O:\>Q:\tools\Python33\python -c print('\u03b1')

It would be a lot better though if it just worked straight away
without me needing to set the code page (like the terminal in every
other OS I use).


More information about the Python-list mailing list