Fixed getting garbled output for some kinds of Unicode characters.