mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user