Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91300 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2015-05-27 21:59 +1000
Last post2015-05-27 21:59 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) Chris Angelico <rosuav@gmail.com> - 2015-05-27 21:59 +1000

#91300 — Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)

FromChris Angelico <rosuav@gmail.com>
Date2015-05-27 21:59 +1000
SubjectRe: Fwd: Lossless bulletproof conversion to unicode (backslashing)
Message-ID<mailman.84.1432727951.5151.python-list@python.org>
On Wed, May 27, 2015 at 9:52 PM, anatoly techtonik <techtonik@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web