Escape characters correctly