#!/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)