so, there is ANSI, WideChar and UTF8 we deal with in RoR atm.
ANSI is used for raw data which comes from some sort of input. UTF-8 is used throughout RoR and for the network code. WideChar (std::wstring) is only used as bridge between ANSI and UTF-8 atm, also most system string operations use wchar_t.
_L() is a UTF-8 encoded UTFString, if we assume the .po file used was using utf8 as well.
L() is a wide char string, which needs to be converted to UTF-8 before we can combine it with other strings: UTFString(L("foobar")), the short form we invented is U("foobar")
UTFString(String("foobar") will not work as the UTFString will assume UTF-8 encoding of the input string. So we need to take a little way around:
ANSI_TO_UTF(String("foobar")) which will convert any ANSI encoded strings into our beloved UTF-8 strings
the problem is now if we hit such code:
Code:
char tmp[128]="";
std::string format = _L("Position: %0.6f s, frame %i / %i");
sprintf(tmp, format.c_str(), ((float)t)/1000000.0f, curOffset, numFrames);
txt->setCaption(String(tmp));
it will break as the format String will be in UTF-8 format if higher characters are used. so we need the wide-char sprintf version:
Code:
wchar_t tmp[128] = L"";
unsigned long t = curFrameTime;
UTFString format = _L("Position: %0.6f s, frame %i / %i");
swprintf(tmp, format.asWStr_c_str(), ((float)t)/1000000.0f, curOffset, numFrames);
txt->setCaption(convertToMyGUIString(tmp, 128));
certainly does not help with readability :|
also, to make the confusion even better, some Parts of Ogre do not understand UTFString, so you get broken info there... :|
so much chaos in the code ... :|