Support non-ascii string and correct an error in writing