Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement