[code.view]

[top] / python / PyMOTW / codecs / codecs_encodings.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: π'
     
     print 'Raw   :', repr(text)
     print 'UTF-8 :', to_hex(text.encode('utf-8'), 1)
     print 'UTF-16:', to_hex(text.encode('utf-16'), 2)
     

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

contact | logmethods.com