X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Futil.cpp;h=45f99e9b5894c83f8cd8d38893d18e8a297de8d6;hp=0fdff6360e8186e3a64faa2f593b8690f75f3afe;hb=e0781eeb34db0aaa775bd3439c1c98103437f009;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/common/util.cpp b/src/common/util.cpp index 0fdff636..45f99e9b 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "util.h" @@ -29,6 +29,10 @@ class QMetaMethod; +// MIBenum values from http://www.iana.org/assignments/character-sets/character-sets.xml#table-character-sets-1 +static QList utf8DetectionBlacklist = QList() + << 39 /* ISO-2022-JP */; + QString nickFromMask(QString mask) { return mask.section('!', 0, 0); @@ -90,6 +94,9 @@ QString stripAcceleratorMarkers(const QString &label_) QString decodeString(const QByteArray &input, QTextCodec *codec) { + if (codec && utf8DetectionBlacklist.contains(codec->mibEnum())) + return codec->toUnicode(input); + // First, we check if it's utf8. It is very improbable to encounter a string that looks like // valid utf8, but in fact is not. This means that if the input string passes as valid utf8, it // is safe to assume that it is.