Add Base::Tools::escapeQuotesFromString with corresponding test
To be used to avoid sending unescaped quotes to python console
This commit is contained in:
committed by
Chris Hennes
parent
02e5c4986d
commit
f5da3925d9
@@ -236,6 +236,26 @@ std::string Base::Tools::escapedUnicodeToUtf8(const std::string& s)
|
||||
return string;
|
||||
}
|
||||
|
||||
std::string Base::Tools::escapeQuotesFromString(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
size_t len = s.size();
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
switch (s.at(i)) {
|
||||
case '\"':
|
||||
result += "\\\"";
|
||||
break;
|
||||
case '\'':
|
||||
result += "\\\'";
|
||||
break;
|
||||
default:
|
||||
result += s.at(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QString Base::Tools::escapeEncodeString(const QString& s)
|
||||
{
|
||||
QString result;
|
||||
|
||||
Reference in New Issue
Block a user