strip_escape_codes as an utility function