2017-12-17 00:01:42 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
namespace chatterino {
|
2018-01-11 20:16:25 +01:00
|
|
|
namespace util {
|
2018-03-31 13:44:15 +02:00
|
|
|
|
|
|
|
inline QString ParseTagString(const QString &input)
|
2017-12-17 00:01:42 +01:00
|
|
|
{
|
|
|
|
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];
|
|
|
|
|
2017-12-17 00:56:33 +01:00
|
|
|
switch (c.cell()) {
|
|
|
|
case 'n': {
|
|
|
|
output[i] = '\n';
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 'r': {
|
|
|
|
output[i] = '\r';
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case 's': {
|
|
|
|
output[i] = ' ';
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case '\\': {
|
|
|
|
output[i] = '\\';
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case ':': {
|
|
|
|
output[i] = ';';
|
|
|
|
} break;
|
|
|
|
|
|
|
|
default: {
|
|
|
|
output[i] = output[i + 1];
|
|
|
|
} break;
|
2017-12-17 00:39:27 +01:00
|
|
|
}
|
2017-12-17 00:56:33 +01:00
|
|
|
|
2017-12-17 00:39:27 +01:00
|
|
|
output[i + 1] = '\0';
|
|
|
|
changed = true;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
return output.replace("\0", "");
|
|
|
|
}
|
2018-03-31 13:44:15 +02:00
|
|
|
|
|
|
|
return output;
|
2017-12-17 00:01:42 +01:00
|
|
|
}
|
2018-03-31 13:44:15 +02:00
|
|
|
|
|
|
|
} // namespace util
|
2017-12-17 00:01:42 +01:00
|
|
|
} // namespace chatterino
|