mirror-chatterino2/src/util/irchelpers.hpp

45 lines
953 B
C++
Raw Normal View History

2017-12-17 00:01:42 +01:00
#pragma once
#include <QString>
namespace chatterino {
QString ParseTagString(const QString &input)
{
QString output = input;
2017-12-17 00:39:27 +01:00
output.detach();
2017-12-17 00:01:42 +01:00
2017-12-17 00:39:27 +01:00
bool changed = false;
2017-12-17 00:01:42 +01:00
2017-12-17 00:39:27 +01:00
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;
}
2017-12-17 00:01:42 +01:00
}
} // namespace chatterino