On Wed, Feb 11, 2009 at 2:50 PM, jeffg <jeffgem...@gmail.com> wrote: > On Feb 11, 2:35 pm, Albert Hopkins <mar...@letterboxes.org> wrote: > > On Wed, 2009-02-11 at 10:35 -0800, jeffg wrote: > > > Having issue on Windows cmd. > > > > Python.exe > > > >>>a = u'\xf0' > > > >>>print a > > > > > This gives a unicode error. > > > > > Works fine in IDLE, PythonWin, and my Macbook but I need to run this > > > from a windows batch. > > > > > Character should look like this "ð". > > > > > Please help! > > > > You forgot to paste the error. > > The error looks like this: > File "<stdin", line 1, in <module> > File "C:\python25\lib\encodings\cp437.py", line 12, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode character u'\xf0' in > position 0 > : character maps to <undefined> > > > Running Python 2.5.4 on Windows XP >
First, you may need to change your command prompt Properties->Font to use Lucida Console rather than raster fonts. Then you'll need to change the code page using chcp to something that has a mapping for the character you want. E.g.: D:\>chcp Active code page: 437 D:\>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a = u'\xf0' >>> print a Traceback (most recent call last): File "<stdin>", line 1, in <module> File "D:\bin\Python2.5.2\lib\encodings\cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character u'\xf0' in position 0: character maps to <undefined> >>> quit() D:\>chcp 1252 Active code page: 1252 D:\>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a = u'\xf0' >>> print a ð >>> quit() D:\> (Just changing the code page works to avoid the UnicodeEncodeError, but with raster fonts that character displays as thee horizontal bars.) Karen
-- http://mail.python.org/mailman/listinfo/python-list