[Qt-creator] UTF-8 Strings in QtCreator source code

Henry Skoglund fromqt at tungware.se
Mon Sep 7 17:11:07 CEST 2015


Hi, actually in my experience with MSVC2013 it's the other way around, 
i.e. as long as MSVC doesn't see any BOMs, you can use UTF-8 strings. 
But if you edit it once in Notepad, *boom* and you lose that availabilty.

For example, create a new Widget app, insert this line in MainWindow.cpp 
just below ui->setupUi(this);

     setWindowTitle("Fleißig in Lübeck");

Compile and you'll see the German umlauts. Edit MainWindow.cpp in 
Notepad and junk will appear instead, because Notepad inserts the BOM.

Rgrds Henry


On 2015-09-07 13:44, André Hartmann wrote:
> Hi Jochen,
>
> if I remember correctly, MSVC (at least older versions) needs a BOM
> (Byte Order Mark) at the file's beginning to detect UTF-8 encoded files.
> Then it should work even without C++11 string constants.
>
> Maybe that's the reason for your problems.
>
> Best regards,
> André
>
> Am 07.09.2015 um 11:49 schrieb Hunger Tobias:
>>> C++11 introduced new UTF-8 string constans, so it should be possible to
>>> write the following:
>>
>>> QStringLiteral(u8"This is a Unicode Character: \u2018.")
>>
>>> and all C++11 compiler should compile it without warnings. Right?
>>
>>> Shall we change the coding style and allow the new UTF-8 string
>>> literals?
>>
>> I rarely use windows, but considering that all Qt 5 code needs to be utf8 encoded anyway, I am a bit surprised that special markup of charcater constants as utf8 are required.
>>
>> Best Regards,
>> Tobias
>>
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>> _______________________________________________
>> Qt-creator mailing list
>> Qt-creator at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>





More information about the Qt-creator mailing list