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

@@ -122,15 +122,14 @@ void CMeasureScript::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
m_MeterWindow->MakePathAbsolute(file);
}
std::string scriptFile = ConvertToAscii(file.c_str());
if (!m_Initialized ||
strcmp(scriptFile.c_str(), m_ScriptFile.c_str()) != 0)
wcscmp(file.c_str(), m_ScriptFile.c_str()) != 0)
{
DeleteLuaScript();
lua_State* L = LuaManager::GetState();
m_ScriptFile = scriptFile;
m_ScriptFile = file;
m_LuaScript = new LuaScript(m_ScriptFile.c_str());
if (m_LuaScript->IsInitialized())
@@ -173,10 +172,7 @@ void CMeasureScript::ReadOptions(CConfigParser& parser, const WCHAR* section)
if (!wstrValue.empty())
{
std::string strStrVal = ConvertToAscii(wstrValue.c_str());
const char* strValue = strStrVal.c_str();
lua_pushstring(L, strValue);
LuaManager::PushWide(L, wstrValue.c_str());
lua_setfield(L, -3, strKey);
}
}
@@ -204,7 +200,7 @@ void CMeasureScript::ReadOptions(CConfigParser& parser, const WCHAR* section)
*/
void CMeasureScript::Command(const std::wstring& command)
{
std::string str = ConvertToAscii(command.c_str());
std::string str = ConvertToUTF8(command.c_str());
m_LuaScript->RunString(str.c_str());
}