-
Notifications
You must be signed in to change notification settings - Fork 365
Open
Description
首先,lua5.4 or lua JIT 宏定义LUA_UCID后是可以支持中文变量,函数
(这条存疑)如果vscode显示文件名不为乱码不用修改
修改LuaPanda.lua取路径函数,处理输入gbk编码时vscode显示文件名为乱码问题
function this.getPath( info )
在函数最后三行,加入编码转换filePath = GbkToUtf8(filePath)
filePath = GbkToUtf8(filePath)
--放入Cache中缓存
this.setCacheFormatPath(originalPath, filePath);
print("filePath " .. filePath)
return filePath;
end //使用sol2进行函数绑定
lua.set_function(u8"GbkToUtf8", [](const std::string& gbkStr) -> std::string {
return 字符串::GbkToUtf8(gbkStr);
});
export std::string GbkToUtf8(std::string src_str)
{
int len = MultiByteToWideChar(CP_ACP, 0, src_str.c_str(), -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, src_str.c_str(), -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
std::string strTemp = str;
if (wstr) delete[] wstr;
if (str) delete[] str;
return strTemp;
}Metadata
Metadata
Assignees
Labels
No labels