improving diagnostics
escaping unsafe characters.

See http://www.rlmueller.net/CharactersEscaped.htm