Fix longstanding bug with invalid unicode symbols appearing in output