implements escapeCharState