Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)

Laura Creighton lac at openend.se
Wed May 27 08:57:01 EDT 2015


Chris Angelico apparantly has a problem with cc'd people who aren't
on the list.  python-list is very quiet these days, so if you
subscribe it won't be drinking from the firehose.  And you can
always turn off delivery when you are done.  Or you can just
go read the archives: https://mail.python.org/pipermail/python-list/2015-May/thread.html

Laura

------- Forwarded Message

Return-Path: <python-list-bounces+lac=openend.se at python.org>
Received: from mail.python.org (mail.python.org [82.94.164.166])
	by theraft.openend.se (8.14.4/8.14.4/Debian-4) with ESMTP id t4RC09ap02From: Chris Angelico <rosuav at gmail.com>
Cc: "python-list at python.org" <python-list at python.org>


On Wed, May 27, 2015 at 9:52 PM, anatoly techtonik <techtonik at gmail.com> wrote:
> And the short answer is that we need unicode because we are printing this
> information to the stdout, and stdout is opened in text mode at least on
> Windows, and without explicit conversion, Python will try to decode stuff
> as being `ascii` and fail anyway.

So you're working with text. That means you HAVE to decode it somehow;
you fundamentally cannot print bytes to the console. Lossless
concealment of arbitrary bytes won't help you. If you can't adequately
decode everything, either backslash-escape the rest, or use a
replacement character; you can't print out those bytes.

And no, I will not cc you. Subscribe to the list if you're going to
ask a question.

ChrisA
- -- 
https://mail.python.org/mailman/listinfo/python-list

------- End of Forwarded Message



More information about the Python-list mailing list