in lib/src/header_parser/sub_parsers/macro_parser.dart [274:316]
String _getWritableChar(int char, {bool utf8 = true}) {
/// Handle control characters.
if (char >= 0 && char < 32 || char == 127) {
/// Handle these - `\b \t \n \v \f \r` as special cases.
switch (char) {
case 8: // \b
return r'\b';
case 9: // \t
return r'\t';
case 10: // \n
return r'\n';
case 11: // \v
return r'\v';
case 12: // \f
return r'\f';
case 13: // \r
return r'\r';
default:
final h = char.toRadixString(16).toUpperCase().padLeft(2, '0');
return '\\x$h';
}
}
/// Handle characters - `$ ' \` these need to be escaped when writing to file.
switch (char) {
case 36: // $
return r'\$';
case 39: // '
return r"\'";
case 92: // \
return r'\\';
}
/// In case encoding is not Utf8, we know all characters will fall in [0..255]
/// Print range [128..255] as `\xHH`.
if (!utf8) {
final h = char.toRadixString(16).toUpperCase().padLeft(2, '0');
return '\\x$h';
}
/// In all other cases, simply convert to string.
return String.fromCharCode(char);
}