infile = open(file)
try:
for line in infile:
- sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "replace"))
+ sys.stdout.write(line.decode(from_charset, "replace").encode(to_charset, "replace"))
except:
infile.close()
else:
for line in sys.stdin:
- sys.stdout.write(unicode(line, from_charset, "replace").encode(to_charset, "replace"))
+ sys.stdout.write(line.decode(from_charset, "replace").encode(to_charset, "replace"))