diff options
-rw-r--r-- | src/libraries/qmfclient/qmailmessage.cpp | 5 | ||||
-rw-r--r-- | tests/tst_python_email/tst_python_email.cpp | 19 | ||||
-rw-r--r-- | tests/tst_qmailcodec/tst_qmailcodec.cpp | 10 | ||||
-rw-r--r-- | tests/tst_qmailmessage/tst_qmailmessage.cpp | 3 | ||||
-rw-r--r-- | tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp | 9 | ||||
-rw-r--r-- | tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp | 17 |
6 files changed, 50 insertions, 13 deletions
diff --git a/src/libraries/qmfclient/qmailmessage.cpp b/src/libraries/qmfclient/qmailmessage.cpp index baf9dd54..38154eba 100644 --- a/src/libraries/qmfclient/qmailmessage.cpp +++ b/src/libraries/qmfclient/qmailmessage.cpp @@ -84,6 +84,9 @@ template<typename CharType> inline bool asciiRepresentable(const CharType& value) { return ((value <= 127) && (value >= 0)); } template<> +inline bool asciiRepresentable<QChar>(const QChar& value) { return value.unicode() <= 127; } + +template<> inline bool asciiRepresentable<unsigned char>(const unsigned char& value) { return (value <= 127); } template<> @@ -3343,7 +3346,7 @@ static bool unicodeConvertingCharset(const QByteArray& charset) // See if this is a unicode-capable codec if (QTextCodec* textCodec = QMailCodec::codecForName(charset, true)) { - const QChar multiByteChar = 0x1234; + const QChar multiByteChar = static_cast<char16_t>(0x1234); return textCodec->canEncode(multiByteChar); } else diff --git a/tests/tst_python_email/tst_python_email.cpp b/tests/tst_python_email/tst_python_email.cpp index 25965eb2..1eb8e570 100644 --- a/tests/tst_python_email/tst_python_email.cpp +++ b/tests/tst_python_email/tst_python_email.cpp @@ -589,7 +589,24 @@ void tst_python_email::test_long_nonstring() // Python appears to identify runs of single-byte characters within unicode strings, and // output them in quoted-printable encoded-words. We don't do that. - QChar chars[] = { 0x6b63, 0x78ba, 0x306b, 0x8a00, 0x3046, 0x3068, 0x7ffb, 0x8a33, 0x306f, 0x3055, 0x308c, 0x3066, 0x3044, 0x307e, 0x305b, 0x3093, 0x3002, 0x4e00, 0x90e8, 0x306f, 0x30c9, 0x30a4, 0x30c4, 0x8a9e, 0x3067, 0x3059, 0x304c, 0x3001, 0x3042, 0x3068, 0x306f, 0x3067, 0x305f, 0x3089, 0x3081, 0x3067, 0x3059, 0x3002, 0x5b9f, 0x969b, 0x306b, 0x306f, 0x300c, 'W', 'e', 'n', 'n', ' ', 'i', 's', 't', ' ', 'd', 'a', 's', ' ', 'N', 'u', 'n', 's', 't', 'u', 'c', 'k', ' ', 'g', 'i', 't', ' ', 'u', 'n', 'd', ' ', 'S', 'l', 'o', 't', 'e', 'r', 'm', 'e', 'y', 'e', 'r', '?', ' ', 'J', 'a', '!', ' ', 'B', 'e', 'i', 'h', 'e', 'r', 'h', 'u', 'n', 'd', ' ', 'd', 'a', 's', ' ', 'O', 'd', 'e', 'r', ' ', 'd', 'i', 'e', ' ', 'F', 'l', 'i', 'p', 'p', 'e', 'r', 'w', 'a', 'l', 'd', 't', ' ', 'g', 'e', 'r', 's', 'p', 'u', 't', '.', 0x300d, 0x3068, 0x8a00, 0x3063, 0x3066, 0x3044, 0x307e, 0x3059, 0x3002 }; + QChar chars[] = { static_cast<char16_t>(0x6b63), static_cast<char16_t>(0x78ba), static_cast<char16_t>(0x306b), static_cast<char16_t>(0x8a00), + static_cast<char16_t>(0x3046), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x7ffb), static_cast<char16_t>(0x8a33), + static_cast<char16_t>(0x306f), static_cast<char16_t>(0x3055), static_cast<char16_t>(0x308c), static_cast<char16_t>(0x3066), + static_cast<char16_t>(0x3044), static_cast<char16_t>(0x307e), static_cast<char16_t>(0x305b), static_cast<char16_t>(0x3093), + static_cast<char16_t>(0x3002), static_cast<char16_t>(0x4e00), static_cast<char16_t>(0x90e8), static_cast<char16_t>(0x306f), + static_cast<char16_t>(0x30c9), static_cast<char16_t>(0x30a4), static_cast<char16_t>(0x30c4), static_cast<char16_t>(0x8a9e), + static_cast<char16_t>(0x3067), static_cast<char16_t>(0x3059), static_cast<char16_t>(0x304c), static_cast<char16_t>(0x3001), + static_cast<char16_t>(0x3042), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x306f), static_cast<char16_t>(0x3067), + static_cast<char16_t>(0x305f), static_cast<char16_t>(0x3089), static_cast<char16_t>(0x3081), static_cast<char16_t>(0x3067), + static_cast<char16_t>(0x3059), static_cast<char16_t>(0x3002), static_cast<char16_t>(0x5b9f), static_cast<char16_t>(0x969b), + static_cast<char16_t>(0x306b), static_cast<char16_t>(0x306f), static_cast<char16_t>(0x300c), + 'W', 'e', 'n', 'n', ' ', 'i', 's', 't', ' ', 'd', 'a', 's', ' ', 'N', 'u', 'n', 's', 't', 'u', 'c', 'k', ' ', 'g', 'i', 't', + ' ', 'u', 'n', 'd', ' ', 'S', 'l', 'o', 't', 'e', 'r', 'm', 'e', 'y', 'e', 'r', '?', ' ', 'J', 'a', '!', ' ', 'B', 'e', 'i', + 'h', 'e', 'r', 'h', 'u', 'n', 'd', ' ', 'd', 'a', 's', ' ', 'O', 'd', 'e', 'r', ' ', 'd', 'i', 'e', ' ', 'F', 'l', 'i', 'p', + 'p', 'e', 'r', 'w', 'a', 'l', 'd', 't', ' ', 'g', 'e', 'r', 's', 'p', 'u', 't', '.', + static_cast<char16_t>(0x300d), static_cast<char16_t>(0x3068), static_cast<char16_t>(0x8a00), static_cast<char16_t>(0x3063), + static_cast<char16_t>(0x3066), static_cast<char16_t>(0x3044), static_cast<char16_t>(0x307e), static_cast<char16_t>(0x3059), + static_cast<char16_t>(0x3002) }; original = QString(chars, sizeof(chars) / sizeof(chars[0])); input.append(' ').append(QMailMessageHeaderField::encodeWord(original, "UTF-8")); diff --git a/tests/tst_qmailcodec/tst_qmailcodec.cpp b/tests/tst_qmailcodec/tst_qmailcodec.cpp index 8dff3d1b..302a33d0 100644 --- a/tests/tst_qmailcodec/tst_qmailcodec.cpp +++ b/tests/tst_qmailcodec/tst_qmailcodec.cpp @@ -131,7 +131,10 @@ void tst_QMailCodec::encode_data() << QByteArray("=23abc_xyz_ABC_XYZ_01_89"); // Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters - const QChar chars[] = { 0x0636, 0x0020, 0x0669, 0x0009, 0x06a5, 0x0020, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0020), + static_cast<char16_t>(0x0669), static_cast<char16_t>(0x0009), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0020), + static_cast<char16_t>(0x06b4) }; QTest::newRow("unicode characters") << QString(chars, 7) << "UTF-8" @@ -689,7 +692,10 @@ void tst_QMailCodec::embedded_newlines() void tst_QMailCodec::encodeDecodeModifiedUtf7() { // Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters - const QChar arabicChars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4, 0x06a5, 0x0669, 0x0636}; + const QChar arabicChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x0636) }; QStringList arabicEncoded = QStringList() << QString::fromLatin1("&BjY-") << QString::fromLatin1("&BjYGaQ-") diff --git a/tests/tst_qmailmessage/tst_qmailmessage.cpp b/tests/tst_qmailmessage/tst_qmailmessage.cpp index ad9d2883..21f33cc0 100644 --- a/tests/tst_qmailmessage/tst_qmailmessage.cpp +++ b/tests/tst_qmailmessage/tst_qmailmessage.cpp @@ -275,7 +275,8 @@ void tst_QMailMessage::toRfc2822_data() QString latin1Address(QString::fromLatin1("\"Joh\361 D\366e\" <jdoe@example.net>")); // Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; QString unicodeAddress(chars, 4); unicodeAddress.append(" <address@test>"); diff --git a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp index 4983541a..0c2cd704 100644 --- a/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp +++ b/tests/tst_qmailmessagebody/tst_qmailmessagebody.cpp @@ -275,7 +275,8 @@ void tst_QMailMessageBody::fromQString_data() << source; // Unicode Characters - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; source = QString(chars, 4); QTest::newRow("unicode - base64") << source @@ -482,7 +483,8 @@ void tst_QMailMessageBody::fromFile_data() << ( QStringList() << "text" << "plain" << "ISO-8859-1" ); // Unicode Characters - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; string_source = QString(chars, 4); QTest::newRow("unicode - string - base64") << string_source @@ -645,7 +647,8 @@ void tst_QMailMessageBody::toFile_data() << encode(bytearray_source, QMailMessageBody::Base64); // Unicode Characters - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; string_source = QString(chars, 4); QTest::newRow("unicode - string - decoded") diff --git a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp index 34d8ae63..64d41174 100644 --- a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp +++ b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp @@ -715,7 +715,8 @@ void tst_QMailMessageHeaderField::decodedContent_data() QTest::addColumn<QString>("result"); // Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters - const QChar arabicChars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar arabicChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; QString unicodeAddress(arabicChars, 4); unicodeAddress.append(" <address@example>"); @@ -735,7 +736,10 @@ void tst_QMailMessageHeaderField::decodedContent_data() input = "=?UTF-8?B?2LYg2akJ2qUg2rQ=?=; param=UTF-8'ar'%D8%B6%D9%A9%DA%A5%DA%B4%20%3Caddress%40example%3E"; - const QChar whitespaceChars[] = { 0x0636, 0x0020, 0x0669, 0x0009, 0x06a5, 0x0020, 0x06b4 }; + const QChar whitespaceChars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0020), + static_cast<char16_t>(0x0669), static_cast<char16_t>(0x0009), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x0020), + static_cast<char16_t>(0x06b4) }; result = QString(whitespaceChars, 7); result += "; "; result += "param*="; @@ -811,7 +815,8 @@ void tst_QMailMessageHeaderField::encodeWord_data() << QByteArray("ISO-8859-1") << QByteArray("=?ISO-8859-1?Q?=28t=C3=ADtulo_=C3=A1guia_Jo=C3=A3o=29?="); - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; QString unicodeAddress(chars, 4); unicodeAddress.append(" <address@example>"); @@ -876,7 +881,8 @@ void tst_QMailMessageHeaderField::encodeParameter_data() QString latin1Address(QString::fromLatin1("\"Joh\361 D\366e\" <jdoe@machine.test>")); // Test with some arabic characters, as per http://en.wikipedia.org/wiki/List_of_Unicode_characters - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; QString unicodeAddress(chars, 4); unicodeAddress.append(" <address@example>"); @@ -1032,7 +1038,8 @@ void tst_QMailMessageHeaderField::encodeContent_data() << QByteArray("ISO-8859-1") << QByteArray("=?ISO-8859-1?Q?=22Joh=F1_D=F6e=22?= =?ISO-8859-1?Q?_=3Cjdoe=40machine=2Etest=3E?="); - const QChar chars[] = { 0x0636, 0x0669, 0x06a5, 0x06b4 }; + const QChar chars[] = { static_cast<char16_t>(0x0636), static_cast<char16_t>(0x0669), + static_cast<char16_t>(0x06a5), static_cast<char16_t>(0x06b4) }; QString unicodeAddress(chars, 4); unicodeAddress.append(" <address@example>"); |