diff options
author | Lars Knoll <[email protected]> | 2020-05-07 16:32:18 +0200 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2020-05-14 19:14:51 +0200 |
commit | b4fd377aa984defea63ecb8951c152872202146e (patch) | |
tree | 18aa45156dce81faf4aebb83a36a58ec5198f763 | |
parent | 9e1dc1e8a9fda1a7576cc6377c8a36decff631eb (diff) |
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 <[email protected]>
-rw-r--r-- | mkspecs/features/default_post.prf | 2 | ||||
-rw-r--r-- | qmake/doc/src/qmake-manual.qdoc | 4 | ||||
-rw-r--r-- | tests/auto/other/compiler/tst_compiler.cpp | 16 |
3 files changed, 19 insertions, 3 deletions
diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 9c73eeef690..b2985fe89c6 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -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 } diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 490d747f1b9..16ed37c0188 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -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 diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 78026665bec..4d19debd069 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -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" |