escape function
Returns output
with all whitespace characters represented as their escape
sequences.
Backslash characters are escaped as \\
Implementation
String escape(String output) {
output = output.replaceAll('\\', r'\\');
return output.replaceAllMapped(_escapeRegExp, (match) {
var mapped = _escapeMap[match[0]];
if (mapped != null) return mapped;
return _hexLiteral(match[0]!);
});
}