"More About Unicode in Python 2 and 3"

Roy Smith roy at panix.com
Sun Jan 5 23:24:11 EST 2014


In article <mailman.5001.1388976943.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> It can't be both things. It's either bytes or it's text. 

I've never used Python 3, so forgive me if these are naive questions.  
Let's say you had an input stream which contained the following hex 
values:

$ hexdump data
0000000 d7 a8 a3 88 96 95

That's EBCDIC for "Python".  What would I write in Python 3 to read that 
file and print it back out as utf-8 encoded Unicode?

Or, how about a slightly different example:

$ hexdump data
0000000 43 6c 67 75 62 61

That's "Python" in rot-13 encoded ascii.  How would I turn that into 
cleartext Unicode in Python 3?



More information about the Python-list mailing list