Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the essential resources for writing internationalized and localized applications in C++?

  • Essential concepts.
  • What string and character data-types to use?
  • What libraries / routines to use for input and output?
  • What translation mechanisms (I guess this would be gettext, libintl)?
  • Porting guidelines?

How far can the standard C/C++ library address the above concerns? How portable can I make my software across platforms? What are the standards / best-practices in this area?

like image 378
CppNoob Avatar asked Dec 05 '25 15:12

CppNoob


1 Answers

I would avoid using wchar_t or std::wstring because this data type is not the same size in different environments. For example on Windows it is 16 bit, while on Unix systems it is 32 bit. Which asks for trouble.

If you don't have time/resources to implement Unicode standard (the bare minimum) yourself, you better off using std::string as a container for UTF-8 characters. Though you must be aware that in the case of UTF-8 you will have to deal with multibyte encoding (1 character may correspond to 1 or more bytes).

As for libraries ICU is something to consider, it will allow you to convert between encodings, transform to upper/lower/title case and etc. It can also help with locales.

Translations as Marius noted are generally done through a function that looks up a table by the key you provided (be it a string, id or anything else) and in the end returns you the translation string.

Porting will go smooth if you stick to using data types that are the same on every platform, not to mention ICU is a cross-platform library, so it must work out.

like image 148
SoulSharer Avatar answered Dec 08 '25 08:12

SoulSharer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!