X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.cpp;h=df23a62e52c5bf1a303c26e7001353bde1cbe93e;hp=80464d87d89d7ca12d3c43122d4a8be452264c75;hb=4676ff82af669595edaf090c97a28161d67782a1;hpb=c371e27b23667e05cccffb200acfb35f5af2a64a diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 80464d87..df23a62e 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -561,15 +561,43 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat QString UiStyle::mircToInternal(const QString &mirc_) { - QString mirc = mirc_; - mirc.replace('%', "%%"); // escape % just to be sure - mirc.replace('\t', " "); // tabs break layout, also this is italics in Konversation - mirc.replace('\x02', "%B"); - mirc.replace('\x0f', "%O"); - mirc.replace('\x12', "%R"); - mirc.replace('\x16', "%R"); - mirc.replace('\x1d', "%S"); - mirc.replace('\x1f', "%U"); + QString mirc; + mirc.reserve(mirc_.size()); + foreach (const QChar &c, mirc_) { + if ((c < '\x20' || c == '\x7f') && c != '\x03') { + switch (c.unicode()) { + case '\x02': + mirc += "%B"; + break; + case '\x0f': + mirc += "%O"; + break; + case '\x12': + case '\x16': + mirc += "%R"; + break; + case '\x1d': + mirc += "%S"; + break; + case '\x1f': + mirc += "%U"; + break; + case '\x7f': + mirc += QChar(0x2421); + break; + default: + mirc += QChar(0x2400 + c.unicode()); + } + } else { + if (c == '\t') { + mirc += " "; + continue; + } + if (c == '%') + mirc += c; + mirc += c; + } + } // Now we bring the color codes (\x03) in a sane format that can be parsed more easily later. // %Dcfxx is foreground, %Dcbxx is background color, where xx is a 2 digit dec number denoting the color code.