summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/codecs/jp/qsjiscodec.cpp4
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp15
2 files changed, 18 insertions, 1 deletions
diff --git a/src/plugins/codecs/jp/qsjiscodec.cpp b/src/plugins/codecs/jp/qsjiscodec.cpp
index 49190d3..3ea5300 100644
--- a/src/plugins/codecs/jp/qsjiscodec.cpp
+++ b/src/plugins/codecs/jp/qsjiscodec.cpp
@@ -155,7 +155,9 @@ QString QSjisCodec::convertToUnicode(const char* chars, int len, ConverterState
uchar ch = chars[i];
switch (nbuf) {
case 0:
- if (ch < 0x80 || IsKana(ch)) {
+ if (ch < 0x80) {
+ result += QValidChar(ch);
+ } else if (IsKana(ch)) {
// JIS X 0201 Latin or JIS X 0201 Kana
u = conv->jisx0201ToUnicode(ch);
result += QValidChar(u);
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index 43656c8..15ecc3b 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -106,6 +106,8 @@ private slots:
void moreToFromUnicode_data();
void moreToFromUnicode();
+
+ void shiftJis();
};
void tst_QTextCodec::toUnicode_data()
@@ -2236,6 +2238,19 @@ void tst_QTextCodec::moreToFromUnicode()
QCOMPARE(testData, cStr);
}
+void tst_QTextCodec::shiftJis()
+{
+ QByteArray backslashTilde("\\~");
+ QTextCodec* codec = QTextCodec::codecForName("shift_jis");
+ QString string = codec->toUnicode(backslashTilde);
+ QCOMPARE(string.length(), 2);
+ QCOMPARE(string.at(0), QChar(QLatin1Char('\\')));
+ QCOMPARE(string.at(1), QChar(QLatin1Char('~')));
+
+ QByteArray encoded = codec->fromUnicode(string);
+ QCOMPARE(encoded, backslashTilde);
+}
+
struct DontCrashAtExit {
~DontCrashAtExit() {
QTextCodec *c = QTextCodec::codecForName("utf8");