I’ve registered LUA api function by using:
lua_register( luaState, "someFunc", aaa::someFunc);
this function has to load a string from the someFunc’s argument.
I am doing it with:
int aaa::someFunc( lua_State* state ) {
const char* _arg = ( const char* )lua_tostring( state, -1 );
// ...
return 0;
}
it works ok, until I put to someFunc() some symbols of my language like: ą, ł, ź etc (it’s ‘a’, ‘l’, ‘z’ written holding ALT key). For these symbols qDebug( “%s”, _arg )* gives me only “?” for them all. How to recognize these values in my program?
For example when I use in my script sendFunc( “Aaś” ) the printed _arg is “Aa?”.
*qDebug is from Qt library, it works the same as printf() but outputs to debug window.
Thanks.
QT uses Unicode strings. I expect that the string returned from Lua is in some other codepage. You’ll need to convert it to Unicode to use with qDebug.
To see what’s really in the string (in terms of hex values), breakpoint your code before calling qDebug.