This line is not modiying buf
as you appear to be thinking:
buf.decode("big5", "strict").encode("utf8", "strict")
You can see in the docs for encode
and decode
. Those methods return strings or unicode objects, they don't modify the calling object. If you want to modify buf
just assign it the result:
buf = buf.decode("big5", "strict").encode("utf8", "strict")
Also if you're on Python2 it doesn't make sense to use parenthesis with print
, can be confusing.