On 16 August 2016 at 14:40, Anthony Briggs <[email protected]> wrote:
> print("M├┐ h├┤v├¿r├ºr├áft ├«├ƒ f├╗┼él ├Âf ├®├¬l┼ø")
>
> works just fine for me, since you're just printing an internal Python
> string.

It will work fine unless you're on Mike's machine - if
sys.stdout.encoding is cp850 and you've got unicode_literals imported
(or are using python3), it won't.

>The problem is from trying to print a binary string (which is what
> you get from .encode()) as an internal Python string. If you specify an
> encoding, the error goes away:
>
> print("M├┐ h├┤v├¿r├ºr├áft ├«├ƒ f├╗┼él ├Âf
> ├®├¬l┼ø".encode("utf-8").decode("cp1252", "replace"))

The only reason to encode to utf-8 and then decode from cp1252 is to
fix incorrect input.

I think you mean .encode("cp1252", "replace").decode("cp1252")

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.
_______________________________________________
melbourne-pug mailing list
[email protected]
https://mail.python.org/mailman/listinfo/melbourne-pug

Reply via email to