Fix encoding

Fix encoding for setEncoding utf-8 or other.