Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. #
  4. # Copyright (c) 2010 Doug Hellmann. All rights reserved.
  5. #
  6. """Demonstrate the representations of values using different encodings.
  7. """
  8. #end_pymotw_header
  9.  
  10. from codecs_to_hex import to_hex
  11.  
  12. text = u'pi: π'
  13. encoded = text.encode('utf-8')
  14. decoded = encoded.decode('utf-8')
  15.  
  16. print 'Original :', repr(text)
  17. print 'Encoded :', to_hex(encoded, 1), type(encoded)
  18. print 'Decoded :', repr(decoded), type(decoded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement