mirror of
https://github.com/GerbilSoft/mst06.git
synced 2025-06-19 03:55:33 -04:00
Mst::escapeDiffOffTbl(): Handle '\n', '\f' and '\\'.
Similar to the regular escaped() function. '\\' is especially needed, since otherwise the escapes wouldn't work correctly.
This commit is contained in:
parent
f570aff7a0
commit
f7ce4f14e7
20
src/Mst.cpp
20
src/Mst.cpp
@ -1143,9 +1143,23 @@ string Mst::escapeDiffOffTbl(const uint8_t *diffTbl, size_t len)
|
||||
for (; len > 0; diffTbl++, len--) {
|
||||
if (*diffTbl < 0x20 || *diffTbl >= 0x7F) {
|
||||
// Escape the character.
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "\\x%02X", *diffTbl);
|
||||
ret += buf;
|
||||
switch (*diffTbl) {
|
||||
case '\\':
|
||||
ret += "\\";
|
||||
break;
|
||||
case '\n':
|
||||
ret += "\\n";
|
||||
break;
|
||||
case '\f':
|
||||
ret += "\\r";
|
||||
break;
|
||||
default: {
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "\\x%02X", *diffTbl);
|
||||
ret += buf;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Use the character as-is.
|
||||
ret += *diffTbl;
|
||||
|
Loading…
Reference in New Issue
Block a user