Revision: 6313
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 15, 2008 18:55 by ckyang74
Initial Code
import sys
from codecs import EncodedFile
## EncodedFile "wraps" stdout so that it always takes a "from_encoding" string and
## convert it to a "to_encoding" string
from_encoding = 'big5'
to_encoding = 'utf8'
sys.stdout = EncodedFile(sys.stdout, from_encoding, to_encoding)
## read a file in big5 encoding
f = file("foo.html", "r")
str = f.read()
## print the content of the file in utf8
sys.stdout.write(str) # you can also use "print str"
Initial URL
Initial Description
Initial Title
read a big5 file and print to stdout in utf8
Initial Tags
python
Initial Language
Python