Page 1 of 1

Some questions about getText() and setText() in lua

Posted: Fri Feb 02, 2007 03:41
by kitejohn
Sample_Demo8:
code as follows:
local text = winMgr:getWindow("Demo8/Window1/Controls/Editbox"):getText()
winMgr:getWindow("Demo8/Window1/Controls/Editbox"):setText(text)

if the string text contains Chinese characters,then i call setText(text),now
you can't see the text of editbox,it has been confused,you just can view another symbol.

I use font simhei-12.font, you can set Chinese characters in c++ code,
for example setText((utf8*)"中"),the editbox can show right, but call
getText() then call setText() in lua,it fails.

it's because of tolua++

Posted: Sat Feb 10, 2007 09:31
by amugana
tolua++ simply maps lua 'string' as CEGUI::String. and tolua++ deals strings as 'const char*'

when u call 'Window::getText',, CEGUI::String automatically decode utf32 string to utf8 and returns utf8 pointer, then 'Window::setText' gets it as 'const char*' so.. CEGUI::String do the encode to utf8 again,,

i got the same prob. in korean lua scripting,, and i got a temporal solution that casting NOT 'const char*' but 'utf8' (in lua_CEGUI.cpp)
so it works for me..

sorry for short english, good luck

to amugana

Posted: Tue Feb 13, 2007 14:01
by kitejohn
amugana sir:
thank you for your kind suggesting and detail decription,and also i will try to find another solution for this,no same way but same aim.
good luck to you.
john.