3 ms·
"even bringing Windows, I repeat WINDOWS, into the fold" I am not a C++ expert but have tinkered with C++11. How will portable C++ work with the Windows UTF-16
by linuxlizard 10y ago
"even bringing Windows, I repeat WINDOWS, into the fold"
I am not a C++ expert but have tinkered with C++11. How will portable C++ work with the Windows UTF-16 (wchar_t) and other systems using UTF-8 (char_t)?
Is there a way to have standard C++ portable across Windows' UTF-16 and !Windows UTF-8 without #ifdef'ing a char wrapper?
edit: UTF-16 not UCS-16
- ComputerGuru 10y agoModern versions of Visual Studio allow you to configure your project as one of ASCII/UNICODE/MBCS. MBCS (multi-byte character set) is UTF8 compatible. TCHAR becomes char (instead of the usual wchar_t) and most APIs you call via their once-ANSI names (e.g. CreateFile being #ifdef'd to CreateFileA) will actually accept UTF8 instead. Unfortunately, APIs that were created when ASCII was declared dead and without an xxxxA counterpart still need manual mapping to the xxxxW functions instead (which is just plain stupid on MS' behalf).
- the_why_of_y 10y ago#ifdefing a leaky abstraction that can be either UTF-8 or UTF-16 would be pretty horrible to work with. For a more workable approach read this article, especially the section "How to do text on Windows". http://utf8everywhere.org/ http://utf8everywhere.org/