On Wed, Feb 11, 2009 at 2:50 PM, jeffg <span dir="ltr"><<a href="mailto:jeffgemail@gmail.com">jeffgemail@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Feb 11, 2:35 pm, Albert Hopkins <<a href="mailto:mar...@letterboxes.org">mar...@letterboxes.org</a>> wrote:<br>
> On Wed, 2009-02-11 at 10:35 -0800, jeffg wrote:<br>
</div><div class="Ih2E3d">> > Having issue on Windows cmd.<br>
> > > Python.exe<br>
> > >>>a = u'\xf0'<br>
> > >>>print a<br>
><br>
> > This gives a unicode error.<br>
><br>
> > Works fine in IDLE, PythonWin, and my Macbook but I need to run this<br>
> > from a windows batch.<br>
><br>
> > Character should look like this "ð".<br>
><br>
> > Please help!<br>
><br>
</div><div class="Ih2E3d">> You forgot to paste the error.<br>
<br>
</div>The error looks like this:<br>
    File "<stdin", line 1, in <module><br>
    File "C:\python25\lib\encodings\cp437.py", line 12, in encode<br>
      return codecs.charmap_encode(input,errors,encoding_map)<br>
UnicodeEncodeError: 'charmap' codec can't encode character u'\xf0' in<br>
position 0<br>
: character maps to <undefined><br>
<br>
<br>
Running Python 2.5.4 on Windows XP<br>
<div><div></div></div></blockquote><div><br>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.:<br>
<br>D:\>chcp<br>Active code page: 437<br><br>D:\>python<br>Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32<br>Type "help", "copyright", "credits" or "license" for more information.<br>
>>> a = u'\xf0'<br>>>> print a<br>Traceback (most recent call last):<br>  File "<stdin>", line 1, in <module><br>  File "D:\bin\Python2.5.2\lib\encodings\cp437.py", line 12, in encode<br>
    return codecs.charmap_encode(input,errors,encoding_map)<br>UnicodeEncodeError: 'charmap' codec can't encode character u'\xf0' in position 0: character maps to <undefined><br>>>> quit()<br>
<br>D:\>chcp 1252<br>Active code page: 1252<br><br>D:\>python<br>Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32<br>Type "help", "copyright", "credits" or "license" for more information.<br>
>>> a = u'\xf0'<br>>>> print a<br>ð<br>>>> quit()<br><br>D:\><br><br>(Just changing the code page works to avoid the UnicodeEncodeError, but with raster fonts that character displays as thee horizontal bars.)<br>
<br>Karen<br></div></div>