Make utf8_source the default for qmake builds
We now assume that source code is encoded in UTF-8 by default on all platforms (and verify this with an auto test). Provide a CONFIG+=no_utf8_source option for backwards compatibility. [ChangeLog][qmake] qmake will tell the compiler that source code is encoded in utf-8 by default. This mainly has an effect on Windows, where MSVC still assumes source code is encoded in the current ANSI code page. Use CONFIG+=no_utf8_source to get back the Qt 5 behavior. Change-Id: I6dcafcaeefdea7d3907ccb723aeb7d23ccc0f04f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
9e1dc1e8a9
commit
b4fd377aa9
@ -166,7 +166,7 @@ c99|c11 {
|
||||
unset(cstd)
|
||||
}
|
||||
|
||||
utf8_source {
|
||||
!no_utf8_source {
|
||||
QMAKE_CFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE
|
||||
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE
|
||||
}
|
||||
|
@ -1147,8 +1147,8 @@
|
||||
default is used.
|
||||
\row \li thread \li Thread support is enabled. This is enabled when CONFIG
|
||||
includes \c qt, which is the default.
|
||||
\row \li utf8_source \li Specifies that the project's source files use the
|
||||
UTF-8 encoding. By default, the compiler default is used.
|
||||
\row \li no_utf8_source \li Specifies that the project's source files does not use
|
||||
the UTF-8 encoding. Instead, the compiler default is used.
|
||||
\row \li hide_symbols \li Set the default visibility of symbols in the binary
|
||||
to hidden. By default, the compiler default is used.
|
||||
\row \li c99 \li C99 support is enabled. This option has no effect if
|
||||
|
@ -115,6 +115,9 @@ private slots:
|
||||
|
||||
/* Future / Technical specification compiler features */
|
||||
void runtimeArrays();
|
||||
|
||||
/* treat source code as utf-8 */
|
||||
void utf8source();
|
||||
};
|
||||
|
||||
#if defined(Q_CC_HPACC)
|
||||
@ -1551,5 +1554,18 @@ void tst_Compiler::runtimeArrays()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tst_Compiler::utf8source()
|
||||
{
|
||||
const char *str = "Ελληνικά";
|
||||
auto u16str = u"Ελληνικά";
|
||||
QCOMPARE(QString::fromUtf16(u16str), QString::fromUtf8(str));
|
||||
|
||||
const char *ae = "\xc3\x86";
|
||||
auto u16ae = u"Æ";
|
||||
QCOMPARE(QString::fromUtf16(u16ae), QString::fromUtf8(ae));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_Compiler)
|
||||
#include "tst_compiler.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user