From 68ee619cbd98ba95c12efb12a7d32d5ca567b40e Mon Sep 17 00:00:00 2001 From: Bas Pape Date: Sun, 3 Feb 2013 14:49:47 +0100 Subject: [PATCH] Add codec blacklist for UTF-8 detection ISO-2022-JP is valid UTF-8, which means this codec needs to bypass the auto-detection. --- src/common/util.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/util.cpp b/src/common/util.cpp index 75f32f2e..45f99e9b 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -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. -- 2.20.1