From 1158e57f400de8f0e9ec0b8b21bfcf0d5dfc830f Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 13 Oct 2015 23:33:26 +0200 Subject: Correctly read octal escapes from Clonk-config --- src/Util.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Util.cpp') diff --git a/src/Util.cpp b/src/Util.cpp index 014f1f8..0a0b6a5 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,5 +1,7 @@ #include "Util.hpp" +#include + namespace Util { QString trimQuotes(QString string, bool& trimmed) { @@ -132,4 +134,16 @@ namespace Util { return ret; } + QString& unescapeClonkString(QString&& string) + { + static QRegularExpression escapeExp(R"(\\[0-7]+)"); + QRegularExpressionMatch match; + while((match = escapeExp.match(string)).hasMatch()) + { + unsigned char c = (unsigned char)match.capturedRef(0).mid(1).toInt(0, 8); + + string.replace(match.capturedStart(), match.capturedLength(), c); + } + return string; + } } -- cgit v1.2.3-54-g00ecf