made text readable (i'm not really confident it works for everyone and all languages though)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3964 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c3f0f7ab82
commit
458e1a19da
@ -183,7 +183,71 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_
|
||||
const char* text = xml->getAttributeValue( "text" );
|
||||
if (text != NULL)
|
||||
{
|
||||
widget.m_text = text; //_(text);
|
||||
/*
|
||||
// FIXME: is this byteswapping necessary on all platforms?
|
||||
stringw byteswap = _(text);
|
||||
const int charcount = byteswap.size();
|
||||
for (int n=0; n<charcount; n++)
|
||||
{
|
||||
short thischar = byteswap[n];
|
||||
char* ptr = (char*)&thischar;
|
||||
char byteA = ptr[0];
|
||||
char byteB = ptr[1];
|
||||
ptr[0] = byteB;
|
||||
ptr[1] = byteA;
|
||||
byteswap[n] = thischar;
|
||||
}
|
||||
widget.m_text = byteswap;
|
||||
*/
|
||||
widget.m_text = _(text);
|
||||
|
||||
const wchar_t* original = _(text);
|
||||
|
||||
std::wcout << L"Output of mbstowcs : " << original << std::endl;
|
||||
|
||||
stringw debug = original;
|
||||
|
||||
//std::wcout << L"Original : " << debug.c_str() << std::endl;
|
||||
|
||||
std::cout << "Before swapping : ";
|
||||
for (int n=0; ; n++)
|
||||
{
|
||||
int thischar = original[n];
|
||||
|
||||
|
||||
if (thischar != (int)debug[n])
|
||||
{
|
||||
std::cerr << "(mismatch : " << thischar << " vs " << (short)debug[n] << ")";
|
||||
}
|
||||
|
||||
if ((thischar & 0xFFFF) == 0)
|
||||
{
|
||||
std::cout << "<EOS>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << (char)(thischar & 0xFF) << "." << (char)((thischar >> 8) & 0xFF) << ".";
|
||||
|
||||
|
||||
if (((thischar >> 16) & 0xFFFF) == 0)
|
||||
{
|
||||
std::cout << "<EOS>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
std::cout << (char)((thischar >> 16) & 0xFF) << "." << (char)((thischar >> 24) & 0xFF) << "/";
|
||||
|
||||
//char* ptr = (char*)&thischar;
|
||||
//char byteA = ptr[0];
|
||||
//char byteB = ptr[1];
|
||||
|
||||
//ptr[0] = byteB;
|
||||
//ptr[1] = byteA;
|
||||
//debug[n] = thischar;
|
||||
}
|
||||
std::cout << "\n";
|
||||
//std::wcout << L"Swapped : " << debug.c_str() << std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -130,7 +130,7 @@ void ProfileWorld::enterRaceOverState(const bool delay)
|
||||
max_t = std::max(max_t, m_kart[i]->getFinishTime());
|
||||
min_t = std::min(min_t, m_kart[i]->getFinishTime());
|
||||
av_t += m_kart[i]->getFinishTime();
|
||||
printf("%s start %d end %d time %f\n",
|
||||
printf("%ls start %d end %d time %f\n",
|
||||
m_kart[i]->getName().c_str(),(int)i,
|
||||
m_kart[i]->getPosition(),
|
||||
m_kart[i]->getFinishTime());
|
||||
|
@ -44,8 +44,18 @@ Translations::Translations() {
|
||||
#endif
|
||||
bindtextdomain (PACKAGE, file_manager->getTranslationDir().c_str());
|
||||
textdomain (PACKAGE);
|
||||
printf("gettext codeset : %s \n", bind_textdomain_codeset(PACKAGE, "UTF-16"));
|
||||
#endif
|
||||
|
||||
} // Translations
|
||||
|
||||
const int BUFFER_SIZE = 512;
|
||||
wchar_t out_buffer[BUFFER_SIZE];
|
||||
|
||||
wchar_t* w_gettext(const char* original)
|
||||
{
|
||||
const char* original_t = gettext(original);
|
||||
|
||||
mbstowcs(out_buffer, original_t, BUFFER_SIZE);
|
||||
|
||||
return out_buffer;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
# include <libintl.h>
|
||||
#endif
|
||||
|
||||
# define _(String) (wchar_t*)gettext(String)
|
||||
# define _(String) w_gettext(String)
|
||||
# define gettext_noop(String) String
|
||||
# define N_(String) gettext_noop (String)
|
||||
// libintl defines its own fprintf, which doesn't work for me :(
|
||||
@ -47,6 +47,8 @@ public:
|
||||
Translations();
|
||||
};
|
||||
|
||||
wchar_t* w_gettext(const char* original);
|
||||
|
||||
extern Translations* translations;
|
||||
#endif
|
||||
/* EOF */
|
||||
|
Loading…
x
Reference in New Issue
Block a user