Home  /  RSS  /  RSS Comments  /  Enter

How not to do Unicode...

Sunday, April 29, 2012, by artyom ; Posted in: Unicode and Localization; 6 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

RPM Repositories for CppCMS

Thursday, March 15, 2012, by artyom ; 0 comments

Additionally to DEB Repositories, RPM repositories are ready as well.

The packages are build using Open Build Service:

http://download.opensuse.org/repositories/home:/artyom-beilis/

CppCMS 1.0.1 - Bug Fix Release

Wednesday, March 14, 2012, by artyom ; 0 comments

CppCMS 1.0.1 Released

It is a bug fix release:

Additionally to the deb releases, now source-rpm is available at sourceforge.

In order to create RPMs for your system:

Install dependent packages:

yum install cmake gcc-c++ gcc make zlib-devel pcre-devel libicu-devel libgcrypt-devel

Download source rpm and rebuild it as:

rpmbuild --rebuild cppcms-1.0.1-1.src.rpm

You will get 3 binary rpm packages: libcppcms, libcppcms-devel and cppcms-tools in the ~/rpmbuild/RPMS/ directory. Install them and use them.

Special Thanks: to Sagi Ben-Akiva for initial spec file that made this process much simpler for me.

CppCMS 1.0.0 released and offered under dual license

Monday, February 27, 2012, by artyom ; 3 comments

CppCMS 1.0.0 was released today. Now it is offered under alternative commercial license. You can choose to use CppCMS under either open source LGPLv3 license or under a commercial license that allows your developing truly closed source applications.

For more details about licensing and pricing please visit our web site:
http://commercial.cppcms.com

The old-stable branch of CppCMS - 0.0.x is now deprecated and would not receive any updates. CppCMS users who still use CppCMS 0.0.8 are encouraged to upgrade to the CppCMS 1.

The new version includes:

You can find more details about the differences between CppCMS 1.0.0 and CppCMS 0.0.8 here

Apt Repositories

Saturday, February 18, 2012, by artyom ; 5 comments

New Apt repositories for Debian and Ubuntu are available.

Read: http://cppcms.com/wikipp/en/page/apt

next page

Pages

Categories