Home  /  RSS  /  RSS Comments  /  RSS for Unicode and Localization  /  Enter

Posts in category ‘Unicode and Localization’.

How not to do Unicode...

Sunday, April 29, 2012, by artyom ; Posted in: Unicode and Localization; 8 comments

All started from a small problem, how to print Unicode text to the Windows Console with option redirect to a file.

Let's say we have a program Hello that prints few words in several languages to the screen..

#include <stdio.h>

int main()
{
    printf("Мир Peace Ειρήνη\n");
    return 0;   
}

The program above is trivial and works fine under Windows if current console codepage is set to UTF-8. Also this can be fixed from the program by calling SetConsolseOutputCP(CP_UTF8).

Now simple tweak... Instead of that standard C printf we would use standard C++ std::cout... It works fine for GCC. But under Visual C++ it prints squares...

If I try redirection test.exe >test.txt - I get perfectly fine UTF-8 text...

I had started researching the issue and found the post of one of the Windows Unicode Gurus Michael Kaplan's.

I've tried to run _setmode(_fileno(stdout), _O_U8TEXT) as recommended by the Microsoft's Unicode guru and... By program crashed on attempt to write to the output stream.

Keeping searching for an answer I've got to this bug report...

Short summary:

To the summary...

If you use Visual C++ you can't use UTF-8 to print text to std::cout.

If you still want to, please read this amazingly long article about how to make wcout and cout working, but it does not really give a simple solution - finally falling to redefinition of the stream buffers...

So please, if you design API or Operating System, do not use kind of "Wide" API... This is is the wrong way to do Unicode.

Which reminds me... Spread around:

http://www.utf8everywhere.org/

Related Posts: http://blog.cppcms.com/post/62

The lecture slides and the poster from August Penguin 2011 conference.

Saturday, August 13, 2011, by artyom ; Posted in: Unicode and Localization; one comment

I had given a lecture at August Penguin conference about Boost.Locale and presented a poster about CppCMS project.

CppCMS 0.99.8 and Boost.Locale 4.0.0 Rleased

Monday, July 11, 2011, by artyom ; Posted in: Progress, Unicode and Localization; 0 comments

New Versions of CppCMS and Boost.Locale were released.

New Features:

Bug Fixes:

Note to SVN-trunk users

Do not forget to untar the updated cppcms_boost.tar.bz2 file.

Boost.Locale was accepted into Boost

Tuesday, April 26, 2011, by artyom ; Posted in: Progress, Unicode and Localization; 4 comments

Now it is official. Boost.Locale was accepted into Boost.

So the Localization part of CppCMS would be spread all over the C++ world.

Formal Review of Boost.Locale starts today

Thursday, April 7, 2011, by artyom ; Posted in: Unicode and Localization; one comment

The formal review of the Boost.Locale library starts today.

I hope it would pass the review and would be accepted as official Boost library.

next page

Pages

Categories