Page 1 of 1
How can I use LUA to set chinese string in CEGUI
Posted: Mon Dec 29, 2008 11:12
by finezwx
I make CEGUI interface use Lua.
and I need Set some chinese string in StaticText.
for Example:
cstrUIHelpWindowHelpText = "大家好"
pWindow = winMgr:getWindow("Root/MainBgImage/TextBgImage/TextWindow")
local myString2,myString = StringToUtf8(cstrUIHelpWindowHelpText,myString1)
pWindow:setText(myString)
StringToUtf8() is a C++ function. and it can work well in C++.
But It's messy code.
Posted: Mon Dec 29, 2008 14:35
by haihuojiming
hi. i know the problem you have.
lua support the asc code, so when you translate the string to unicode, you won't have the right result.
I'm Chinese too, add me msn
haihuogeming#163.com .. maybe i can help you
Posted: Mon Dec 29, 2008 14:54
by scriptkid
Exactly, it's about the ascii support in lua. What i did for a project was come up with a helper function which i did bind:
Code: Select all
void Gui::setWinTextUTF8(std::string winName, std::string winText)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
if (winMgr.isWindowPresent(winName))
{
CEGUI::Window* win = winMgr.getWindow(winName);
win->setText((CEGUI::utf8*)winText.c_str());
}
}
which you could call as:
Code: Select all
gui_wrapper:setWinTextUTF8("Root/MainBgImage/TextBgImage/TextWindow", "大家好");
So that you don't have a conversion 'through' the binding. I can confirm that it works for Japanese and Korean at least.
HTH.
Posted: Tue Dec 30, 2008 16:13
by haihuojiming
the function works for Chinese too .
i add a a method setTextA to base class CEGUI::Window, it use a virtual interface to tanslate the code.
but... ... scriptkid
do you forget to use a transform funtion for ascToUTF8 ?
--------------------------------------------------------------------------------
void Gui::setWinTextUTF8(std::string winName, std::string winText)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
if (winMgr.isWindowPresent(winName))
{
CEGUI::Window* win = winMgr.getWindow(winName);
--
CEGUI::String UtfText = (CEGUI::utf8*)ascToUtf8(winText.c_str());
--
win->setText(UtfText );
--
}
}
---------------------------------------------------------------------------------
Posted: Wed Dec 31, 2008 01:16
by finezwx
thank you very much.
and I have take a try, It worked for me.
I didn't use msn. and this is my QQ:173683327