[code.view]

[top] / python / PyMOTW / codecs / codecs_decode.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Demonstrate the representations of values using different encodings.
     """
     #end_pymotw_header
     
     from codecs_to_hex import to_hex
     
     text = u'pi: π'
     encoded = text.encode('utf-8')
     decoded = encoded.decode('utf-8')
     
     print 'Original :', repr(text)
     print 'Encoded  :', to_hex(encoded, 1), type(encoded)
     print 'Decoded  :', repr(decoded), type(decoded)
     

[top] / python / PyMOTW / codecs / codecs_decode.py

contact | logmethods.com