added ParseTagString code

This commit is contained in:
2017-12-17 00:39:27 +01:00
parent 269a5500d8
commit 6b46d12558

View file

@ -7,10 +7,38 @@ namespace chatterino {
QString ParseTagString(const QString &input) QString ParseTagString(const QString &input)
{ {
QString output = input; QString output = input;
output.detach();
// code goes here bool changed = false;
return output; for (int i = 0; i < output.length() - 1; i++) {
if (output[i] == '\\') {
QChar c = output[i + 1];
if (c == 'n') {
output[i] == '\n';
} else if (c == 'r') {
output[i] == '\r';
} else if (c == 's') {
output[i] == ' ';
} else if (c == '\\') {
output[i] == '\\';
} else if (c == ':') {
output[i] == ';';
} else {
output[i] = output[i + 1];
}
output[i + 1] = '\0';
changed = true;
i++;
}
}
if (changed) {
return output.replace("\0", "");
} else {
return output;
}
} }
} // namespace chatterino } // namespace chatterino