<br><br><div class="gmail_quote">On Wed, Feb 11, 2009 at 5:10 PM, jeffg <span dir="ltr"><<a href="mailto:jeffgemail@gmail.com">jeffgemail@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Feb 11, 3:57 pm, "Martin v. Löwis" <<a href="mailto:mar...@v.loewis.de">mar...@v.loewis.de</a>> wrote:<br>
> > 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>
> Well, your terminal just cannot display this character by default; you<br>
> need to use a different terminal program, or reconfigure your terminal.<br>
><br>
> For example, do<br>
><br>
> chcp 1252<br>
><br>
> and select Lucida Console as the terminal font, then try again.<br>
><br>
> Of course, this will cause *different* characters to become<br>
> non-displayable.<br>
><br>
> Regards,<br>
> Martin<br>
<br>
Thanks, I ended up using encode('iso-8859-15', "replace")<br>
Perhaps more up to date than cp1252...??</blockquote><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
It still didn't print correctly, but it did write correctly, which was<br>
my main problem.</blockquote><div><br>Let me guess, it showed up as <b>≡</b><b>. </b>This is the cp437 symbol at 0xf0. <br><div><br>When Python sends the string to stdout, it doesn't send characters, it sends a stream of bytes. It is up to the file or file-like object at the other end (in this case, cmd.exe) to interpret those bytes. Both cp1252 and ISO-8859-15 interpret the byte /xf0 as ð. When you opened the text file, it probbly opened as cp1252 because that's the Windows default. If you change the terminal encoding, it will display correctly for the same reason.<br>
<br><br></div><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>