2

I'm writing a C++ application which shall be locale independent, so I decided to use UTF-16 as my in-memory representation for strings/texts (the application should be as platform independent as possible). For localize the application's messages i want to use GNU's gettext library. Since this library seems to use GNU's libunistring library internally, i want to use this one too.

Is this a good solution for i18n, l10n? I mean it will be a lot of C code in my C++ classes (I don't found a C++ Wrapper for the libunistring library).

Stefan

PS: It's my first big C++ application.

Stefan
  • 776
  • 1
  • 8
  • 17
  • Is this a gui application? If this is what toolkit are you writing it in? – Roman A. Taycher Oct 03 '10 at 11:07
  • Yes, it should be a GUI application, but I want to write a command line interface first, so I dont't choosed a toolkit yet. – Stefan Oct 03 '10 at 11:26
  • The question about GUI is valid, as Qt for example have built-in representation for Unicode strings (QString). And different (non-gettext) localization model. It could be easier (but not necessary better) approach. – Paweł Dyda Oct 03 '10 at 15:29
  • @Pawel Dyda: I don't know Qt's localization model before - will have a lokk at it . – Stefan Oct 03 '10 at 16:43

2 Answers2

3

Use UTF8 instead. see :

Community
  • 1
  • 1
Klaim
  • 67,274
  • 36
  • 133
  • 188
  • The libunistring library also supports UTF-8 as in-memory representation, so it's no problem to use it. Do you know a better library for doing this? The libunistring one seems to be not not so good documented. – Stefan Oct 03 '10 at 11:30
  • @Downvoter: Using UTF-16 in C++ code could be problematic, especially if one needs to convert between UTF-16 and UTF-8. I don't see valid reason for downvoting this answer. – Paweł Dyda Oct 03 '10 at 15:27
1

If it is a gui application written in c++, qt might be a good toolkit to do it in. It includes its own string class and its own internationalization support:

http://doc.trolltech.com/4.7/internationalization.html.

Also you can use the core non gui classes by themselves(they are in their own QtCore namespace separate form the QtGui namespace, and there are compiled to separate dynamically linked libraries).

Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141