on xenial help sign in
Now unicode happy
4abf593Ted Gould
plugins/Unity/Launcher/backend/launcherbackend.cpp+3−3
@@ -515,7 +515,7 @@ QString LauncherBackend::decodeAppId (const QString& path)
515 }
515 }
516 }
516 }
517
517
518− return decoded;
518+ return QString::fromUtf8(decoded);
519}
519}
520
520
521QString LauncherBackend::encodeAppId (const QString& appId)
521QString LauncherBackend::encodeAppId (const QString& appId)
@@ -524,14 +524,14 @@ QString LauncherBackend::encodeAppId (const QString& appId)
524 QString encoded;
524 QString encoded;
525
525
526 for (int i = 0; i < bytes.size(); ++i) {
526 for (int i = 0; i < bytes.size(); ++i) {
527− char chr = bytes.at(i);
527+ uchar chr = bytes.at(i);
528
528
529 if ((chr >= 'a' && chr <= 'z') ||
529 if ((chr >= 'a' && chr <= 'z') ||
530 (chr >= 'A' && chr <= 'Z') ||
530 (chr >= 'A' && chr <= 'Z') ||
531 (chr >= '0' && chr <= '9'&& i != 0)) {
531 (chr >= '0' && chr <= '9'&& i != 0)) {
532 encoded.append(chr);
532 encoded.append(chr);
533 } else {
533 } else {
534− QString hexval = QString("_%1").arg((ushort)chr, 2, 16, QChar('0'));
534+ QString hexval = QString("_%1").arg(chr, 2, 16, QChar('0'));
535 encoded.append(hexval.toUpper());
535 encoded.append(hexval.toUpper());
536 }
536 }
537 }
537 }
tests/plugins/Unity/Launcher/launcherbackendtest.cpp+4−4
@@ -120,18 +120,18 @@ private Q_SLOTS:
120 QTest::newRow("Hyphen test") << "typical-application" << "typical_2Dapplication";
120 QTest::newRow("Hyphen test") << "typical-application" << "typical_2Dapplication";
121
121
122 /* Japanese test */
122 /* Japanese test */
123− QTest::newRow("日本語 test") << "日本語" << "_65_E5_67_2C_8A_9E";
123+ QTest::newRow("日本語 test") << "日本語" << "_E6_97_A5_E6_9C_AC_E8_AA_9E";
124 }
124 }
125
125
126 void testDbusName() {
126 void testDbusName() {
127 QFETCH(QString, decoded);
127 QFETCH(QString, decoded);
128 QFETCH(QString, encoded);
128 QFETCH(QString, encoded);
129
129
130− QString decodeOut = LauncherBackend::decodeAppId(encoded);
131− QCOMPARE(decoded, decodeOut);
132−
133 QString encodeOut = LauncherBackend::encodeAppId(decoded);
130 QString encodeOut = LauncherBackend::encodeAppId(decoded);
134 QCOMPARE(encoded, encodeOut);
131 QCOMPARE(encoded, encodeOut);
132+
133+ QString decodeOut = LauncherBackend::decodeAppId(encoded);
134+ QCOMPARE(decoded, decodeOut);
135 }
135 }
136};
136};
137
137