|
|
@ -140,3 +140,30 @@ string StringUtils::bytet2BinaryBigEnd(uint32_t value, int bitCount, bool remote |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
string StringUtils::escapeSequence(const string& raw_str) { |
|
|
|
string escaped_str; |
|
|
|
for (const char& ch : raw_str) { |
|
|
|
switch (ch) { |
|
|
|
case '\n': |
|
|
|
escaped_str.append("\\n"); |
|
|
|
break; |
|
|
|
case '\r': |
|
|
|
escaped_str.append("\\r"); |
|
|
|
break; |
|
|
|
case '\t': |
|
|
|
escaped_str.append("\\t"); |
|
|
|
break; |
|
|
|
case '\"': |
|
|
|
escaped_str.append("\\\""); |
|
|
|
break; |
|
|
|
case '\\': |
|
|
|
escaped_str.append("\\\\"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
escaped_str.push_back(ch); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return escaped_str; |
|
|
|
} |