2016-12-13 | Paul Boddie | raw annotate files changeset graph | Added encoding attributes and text encoding/decoding support to file streams. Added a test of Unicode object creation and output. |
1 # -*- coding: ISO-8859-1 -*- 2 3 import sys 4 5 # Print bytes. 6 7 s = "???" 8 print s # ??? 9 10 # Obtain text and print it. 11 12 u = unicode(s, "ISO-8859-1") 13 print u # ?????? 14 print u.encode("ISO-8859-1") # ??? 15 16 # Inspect and update the encoding of stdout. 17 18 print sys.stdout.encoding # None 19 sys.stdout.encoding = "ISO-8859-1" 20 print u # ???