Script: Added Unicode support

The script file can now be UTF8 encoded. There are some limitations with UTF8 data and the Lua string library, check: http://lua-users.org/lists/lua-l/2012-02/msg00241.html
This commit is contained in:
Birunthan Mohanathas
2012-07-13 14:36:59 +03:00
parent dcdee91670
commit 99c67f7dac
6 changed files with 69 additions and 36 deletions

View File

@@ -61,27 +61,15 @@ void LuaManager::ReportErrors(lua_State* L)
const char* error = lua_tostring(L, -1);
lua_pop(L, 1);
const char* pos = error + 4; // Skip the drive
// Get rid of everything up to the filename
while (*pos != ':')
{
if (*pos == '\\')
{
error = pos + 1;
}
++pos;
}
LogWithArgs(LOG_ERROR, L"Script: %S", error);
}
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
{
lua_pushstring(L, ConvertToAscii(str).c_str());
lua_pushstring(L, ConvertToUTF8(str).c_str());
}
std::wstring LuaManager::ToWide(lua_State* L, int narg)
{
return ConvertToWide(lua_tostring(L, narg));
return ConvertUTF8ToWide(lua_tostring(L, narg));
}