[Interest] Unicode code points in Vusual Studio. Output differs from MinGW

Viktor Engelmann viktor.engelmann at qt.io
Tue Aug 16 15:29:38 CEST 2016


How can you code in notepad? That is just asking for trouble. At least
take Notepad++.

When you look at the internals, you see that UTF-8 is extremely well
designed and almost always works nicely with everything except notepad
and cmd.com.

When your source file is UTF-8 encoded (which IMHO it should always be)
and the terminal program is set to UTF-8 (which it also should always
be), then you can even compile with a compiler that doesn't support
UTF-8. I don't even use html entities anymore - I just deliberately save
in UTF-8, put the encoding in the head (for Windows) and use Unicode all
I want.

IMHO, we should really seek to encode */everything in the world/* in
UTF-8 and dismiss all other encodings.
(wishful thinking)

Viktor


On 11.08.2016 23:07, Henry Skoglund wrote:
> On 2016-08-11 19:53, Mark Gaiser wrote:
>> On Thu, Aug 11, 2016 at 6:29 PM, Thiago Macieira
>> <thiago.macieira at intel.com <mailto:thiago.macieira at intel.com>> wrote:
>>
>>     On quinta-feira, 11 de agosto de 2016 11:40:46 PDT Mark Gaiser
>> wrote:
>>     > Is there any way that i can use a string with unicode code
>> points within
>>     > tr(...) that works on MSVC 2010 (as that is my setup), but it
>> would be
>>     > great if it also works under MSVC 2015 and MinGW.
>>
>>     There's no way to make that work with MSVC 2010. If you want this to
>>     work,
>>     your options are:
>>
> ..
> ..
>> The only option i seem to have left for 2010 are apparently:
>> - Making sure the source files are UTF-8 formatted (most is ascii at the
>> moment)
>> - Using tr("Coördinaat"); as opposed to tr("Co\u00F6rdinaat");, that
>> does work, but is not preferred.
>
> Actually it's possible to use unicode code points in tr(...) you just
> have to know how to play hardball with the compiler :-)
>
> Instead of trying to play nice with tr("Co\u00F6rdinaat"); you use
> tr("Co\xC3\xB6rdinaat");
>
> Yes \uC3B6 is the UTF-8 encoding of the Unicode code point U+00F6
> (if you type in tr("Coördinaat") and then hexdump the .exe file you'll
> see those bytes.)
>
> Effectively you're saying to the compiler: don't mind us hex bytes
> passing, we're not the unicode characters you're looking for. This
> works as long as none of the 2, 3 or 4 UTF-8 characters are null chaps.
>
> I've used this trick on MSVC2012 and MSVC2013, so it should work in
> MSVC2010 as well. (The reason: usually I code (Swedish) characters
> with tr("Coöordinaat"); but this is brittle, because then Notepad
> becomes your enemy. If you're tired one day and make a quick edit in
> Notepad on your mainwindow.cpp, Notepad "helps" your by inserting the
> BOM and *BOOM* tr("Coördinaat") does not longer compile correctly, but
> tr("Co\xC3\xB6rdinaat") does.)
>
> Rgrds Henry
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-- 


Viktor Engelmann
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
Viktor.Engelmann at qt.io
+49 151 26784521
http://qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
<http://qt.io>
<http://www.facebook.com/Qt> 	<http://www.twitter.com/qtproject>
<https://www.linkedin.com/company/the-qt-company/>
<https://plus.google.com/104580575722059274792>
<https://www.youtube.com/QtStudios>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_logo_with_text_green_rgb_400x141.png
Type: image/png
Size: 16849 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_facebook.png
Type: image/png
Size: 1407 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_twitter.png
Type: image/png
Size: 1778 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_linkedin.png
Type: image/png
Size: 1532 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_googleplus.png
Type: image/png
Size: 1957 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_youtube.png
Type: image/png
Size: 1610 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: viktor_engelmann.vcf
Type: text/x-vcard
Size: 271 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160816/ae4ff6d9/attachment.vcf>


More information about the Interest mailing list