On 14/03/2019 16.50, Matthew Woehlke wrote: > While working on some modernization of my application — in particular, > converting some UTF-8 literals to use QStringLiteral — I noticed a > concerning compiler warning: > > warning C4566: character represented by universal-character-name > '\uXXXX' cannot be represented in the current code page (1252) > > After doing some testing, it turns out that, given code like > QStringLiteral("\u269E \U0001f387 \u269F"), MSVC is indeed butchering > the string. > > Further investigation shows that the problem seems to be with the > implementation of QStringLiteral. In particular, it appears that the > preprocessor initially sees just the raw string literal without the 'u' > prefix, butchers it, then later "promotes" it to a UTF-16 literal, but > by then the damage has been done. > > While this absolutely feels like a compiler bug, it's an *awful* big > gotcha that probably should be documented. Also, is there anything that > Qt can do to work around it? (I know these sorts of macro expansions can > be tricksy...) > > Note: and the *local* work-around is apparently to include the 'u' > prefix on my own literal; apparently doubling it (`uu"stuff"`) is okay.
...forgot to mention; previous mail attempted to have a complete test case attached, except I accidentally applied the work-around and saved it before sending the message. So, to see the problem, build the attached source (with VC++), but remove the 'u' prefix from the QStringLiteral. -- Matthew _______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development