From f1f08af4d7a1b4bedf55fb25af974276e5eb858c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 12 Jul 2015 20:40:10 +0000 Subject: MirLua: - Utf8Decode? functions are returns strings (thx to Mironych) - added DecodeCustomButtonClickData to m_msg_buttonsbar - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14546 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_utils.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'plugins/MirLua/src/mlua_utils.cpp') diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index 7fa59212c5..31af863da2 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -38,6 +38,32 @@ int luaM_atpanic(lua_State *L) return 0; } +int luaM_toansi(lua_State *L) +{ + const char* value = luaL_checkstring(L, 1); + int codepage = luaL_optinteger(L, 2, Langpack_GetDefaultCodePage()); + + ptrA string(mir_strdup(value)); + lua_pushstring(L, mir_utf8decodecp(string, codepage, NULL)); + + return 1; +} + +int luaM_toucs2(lua_State *L) +{ + const char* value = luaL_checkstring(L, 1); + + ptrW unicode(mir_utf8decodeW(value)); + size_t length = mir_wstrlen(unicode) * sizeof(wchar_t); + + ptrA string((char*)mir_calloc(length + 1)); + memcpy(string, unicode, length); + + lua_pushlstring(L, string, length + 1); + + return 1; +} + bool luaM_toboolean(lua_State *L, int idx) { if (lua_type(L, idx) == LUA_TNUMBER) @@ -56,6 +82,9 @@ WPARAM luaM_towparam(lua_State *L, int idx) case LUA_TNUMBER: wParam = lua_tonumber(L, idx); break; + case LUA_TSTRING: + wParam = (WPARAM)lua_tostring(L, idx); + break; case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: wParam = (WPARAM)lua_touserdata(L, idx); @@ -75,6 +104,9 @@ LPARAM luaM_tolparam(lua_State *L, int idx) case LUA_TNUMBER: lParam = lua_tonumber(L, idx); break; + case LUA_TSTRING: + lParam = (LPARAM)lua_tostring(L, idx); + break; case LUA_TUSERDATA: case LUA_TLIGHTUSERDATA: lParam = (LPARAM)lua_touserdata(L, idx); -- cgit v1.2.3