From 619988b2909f1e10cc1ceca229e1c83e695b5daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?"Adri=C3=A1n=20Chaves=20Fern=C3=A1ndez=20(Gallaecio)"?= Date: Sat, 1 Dec 2012 17:08:49 +0100 Subject: [PATCH] An UTF-8 character is now used to represent the ASCII control characters whose functionality is not meant to be used. --- src/uisupport/uistyle.cpp | 52 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 6bd8494..fac2ae2 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -563,13 +563,51 @@ 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"); + + // ASCII Control Characters. + // + // There are some unicode characters reserved for representing control characters when it is necessary to print them + // rather than have them perform their intended function. + // + // So, for those that are not given a functionality, the UTF-8 character will be used instead. + // + // See: http://en.wikipedia.org/wiki/ASCII#ASCII_control_characters + // + // The null character, ‘\x00’, is never found in the string. + // The start of header, ‘\x01’, is never found in the string. + mirc.replace('\x02', "%B"); // Bold. + // ‘\x03’ will be managed later, for color stuff. + mirc.replace('\x04', QString::fromUtf8("␄")); + mirc.replace('\x05', QString::fromUtf8("␅")); + mirc.replace('\x06', QString::fromUtf8("␆")); + mirc.replace('\x07', QString::fromUtf8("␇")); + mirc.replace('\x08', QString::fromUtf8("␈")); + mirc.replace('\x09', " "); // Tab, in spaces. + // No need to manage ‘\x0a’, line feeds end the message and write the following characters in another message. + mirc.replace('\x0b', QString::fromUtf8("␋")); + mirc.replace('\x0c', QString::fromUtf8("␌")); + // The carriage return, ‘\x0d’, is never found in the string. + mirc.replace('\x0d', QString::fromUtf8("␍")); + mirc.replace('\x0e', QString::fromUtf8("␎")); + mirc.replace('\x0f', "%O"); // ? + mirc.replace('\x10', QString::fromUtf8("␐")); + mirc.replace('\x11', QString::fromUtf8("␑")); + mirc.replace('\x12', "%R"); // ? + mirc.replace('\x13', QString::fromUtf8("␓")); + mirc.replace('\x14', QString::fromUtf8("␔")); + mirc.replace('\x15', QString::fromUtf8("␕")); + mirc.replace('\x16', "%R"); // ? + mirc.replace('\x17', QString::fromUtf8("␗")); + mirc.replace('\x18', QString::fromUtf8("␘")); + mirc.replace('\x19', QString::fromUtf8("␙")); + mirc.replace('\x1a', QString::fromUtf8("␚")); + mirc.replace('\x1b', QString::fromUtf8("␛")); + mirc.replace('\x1c', QString::fromUtf8("␜")); + mirc.replace('\x1d', "%S"); // Italics. + mirc.replace('\x1e', QString::fromUtf8("␞")); + mirc.replace('\x1f', "%U"); // Underlined. + + mirc.replace('\x7f', QString::fromUtf8("␡")); // 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. -- 1.8.0