1、增加utf8支持2021在线班郁金香灬老师 QQ 150330575交流群:158280115学习目标: 增加utf8支持CastSpellByName(霜甲术)#includepch.htypedef int (*TluaL_loadbuffer)(UINT_PTR L,const char*s1, int len, const char*s2);TluaL_loadbuffer luaL_loadbuffer = (TluaL_loadbuffer)0x0084F860;/LUA_API int lua_pcall (lua_State *L, int nargs, int nresult
2、s, int errfunc)typedef int(*Tlua_pcall)(UINT_PTR L,int nargs, int nresults, int errfunc);Tlua_pcall lua_pcall = (Tlua_pcall)0x0084EC50;int _cdecl luaL_loadstring(UINT_PTR L, const char *s)return luaL_loadbuffer(L, s, strlen(s), s);/* #define luaL_dostring(L, s) (luaL_loadstring(L, s) | lua_pcall(L,
3、0, LUA_MULTRET, 0)*/#define LUA_MULTRET (-1)int luaL_dostring(UINT_PTR L指针, const char*strlua)/DWORD AnsiToUtf8(IN LPCSTR Ansi, OUT LPSTR szpUtf8Buf, SIZE_T bufsize);/ANSI字符转换成utf8格式size_t 长度 = strlen(strlua);/malloc free/char* 新空间 = new char长度 * 2;/luaL_loadstring(L指针, strlua);/delete 新空间;/释放掉空间size_t bufsize = 长度 * 2;char* szpUtf8Buf =(char*) malloc(bufsize);AnsiToUtf8(strlua, szpUtf8Buf, bufsize);luaL_loadstring(L指针, szpUtf8Buf);free(szpUtf8Buf);/释放掉空间return lua_pcall(L指针, 0, LUA_MULTRET, 0);