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


Groups > comp.lang.python > #44607

Re: How do I encode and decode this data to write to a file?

Date 2013-05-01 19:36 -0400
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: How do I encode and decode this data to write to a file?
References <27s15a-943.ln1@chris.zbmc.eu>
Newsgroups comp.lang.python
Message-ID <mailman.1226.1367451385.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 4/29/2013 5:47 AM, cl@isbd.net wrote:
> If I understand correctly the encode() is saying that it can't
> understand the data in the html because there's a character 0xc3 in it.
> I *think* this means that the é is encoded in UTF-8 already in the
> incoming data stream (should be as my system is wholly UTF-8 as far as I
> know and I created the directory name).
>
> So how do I change the code so I don't get the error?  Do I just
> decode() the data first and then encode() it?
>

BTW, I did a presentation at PyCon 2012 that many people have found 
helpful: Pragmatic Unicode, or, How Do I Stop the Pain: 
http://nedbatchelder.com/text/unipain.html .  It explains the principles 
at work here.

--Ned.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How do I encode and decode this data to write to a file? cl@isbd.net - 2013-04-29 10:47 +0100
  Re: How do I encode and decode this data to write to a file? Andrew Berg <bahamutzero8825@gmail.com> - 2013-04-29 05:11 -0500
    Re: How do I encode and decode this data to write to a file? cl@isbd.net - 2013-04-29 13:50 +0100
  Re: How do I encode and decode this data to write to a file? Peter Otten <__peter__@web.de> - 2013-04-29 12:33 +0200
  Re: How do I encode and decode this data to write to a file? Dave Angel <davea@davea.name> - 2013-04-29 07:46 -0400
    Re: How do I encode and decode this data to write to a file? cl@isbd.net - 2013-04-29 13:59 +0100
      Re: How do I encode and decode this data to write to a file? Robert Kern <robert.kern@gmail.com> - 2013-04-29 14:11 +0100
        Re: How do I encode and decode this data to write to a file? cl@isbd.net - 2013-04-29 15:38 +0100
          Re: How do I encode and decode this data to write to a file? Skip Montanaro <skip@pobox.com> - 2013-04-29 09:56 -0500
  Re: How do I encode and decode this data to write to a file? Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-29 18:02 -0400
  Re: How do I encode and decode this data to write to a file? Tony the Tiger <tony@tiger.invalid> - 2013-05-01 16:20 -0500
    Re: How do I encode and decode this data to write to a file? Ned Batchelder <ned@nedbatchelder.com> - 2013-05-01 18:01 -0400
  Re: How do I encode and decode this data to write to a file? Ned Batchelder <ned@nedbatchelder.com> - 2013-05-01 19:36 -0400

csiph-web