PDA

View Full Version : How to use different codepage for fonts



Rouves
08-29-2013, 07:58 PM
Hello all,

I want to use the codepage 1250 for Central Europe. I think it is the right for writing in german but I can only load predefined codepages like ansi_charset. Is there a posibility to use that codepage or add it in the source code and compile it to use it?

I hope you have an answer.

Rouves

Judas
08-29-2013, 11:24 PM
All strings in ClanLib are UTF-8 encoded. This means that when you call draw_text it expects the text in the supplied std::string to be UTF-8, and therefore supports rendering all german characters.

If you are thinking of characters written as strings inside a .cpp file, like this:


std::string foo = "aber warüm";

then the actual encoding of such a string depends on the compiler. Per default, I believe Visual C++ uses the local ANSI codepage for your Windows. On Unix it probably uses the lang environment variable (its actual name escapes me right now), which on modern Linux typically means UTF-8.

In either case your source file will not be very cross platform (i.e. for VC++ your program would compile incorrectly with the ISO-8859-1 charset or whatever a danish Windows might use). I therefore highly recommend against using other than ASCII characters in strings in .cpp files.

The best solution is probably to place your localized strings in some xml or text file, preferrably UTF-8 encoded. Also, the built-in character set converting functions in ClanLib can all be found in the StringHelp class, if you need to do conversion to/from UTF-8.