One option is to iterate over the string with a regular expression:
QString value
= "\\x5cx21\\x21def\\x21ghi\\x23";
const QRegExp re
("\\\\x([0-9a-f]{2})");
int pos = 0;
while ((pos = re.indexIn(value, pos)) != -1) {
bool ok;
int v = re.cap(1).toInt(&ok, 16);
value
= value.
replace(pos,
4,
QChar(v
));
++pos;
}
QString value = "\\x5cx21\\x21def\\x21ghi\\x23";
const QRegExp re("\\\\x([0-9a-f]{2})");
int pos = 0;
while ((pos = re.indexIn(value, pos)) != -1) {
bool ok;
int v = re.cap(1).toInt(&ok, 16);
value = value.replace(pos, 4, QChar(v));
++pos;
}
To copy to clipboard, switch view to plain text mode
Bookmarks