增加Lua导出和FileList

This commit is contained in:
2025-09-02 20:39:30 +08:00
parent 1fb319f0e8
commit 6788128cc3
18 changed files with 682 additions and 56 deletions
+46
View File
@@ -109,6 +109,52 @@ std::wstring convertAnsiStringToWide(const char* szSource)
return strReturn;
}
std::string convertWideStringToUtf8(const wchar_t* source)
{
const static int DEFAULT_CHAR_BUF_SIZE = 1024;
char DEFAULT_CHAR_BUF[DEFAULT_CHAR_BUF_SIZE] = { 0 };
if(source==nullptr || source[0]==L'\0')
return std::string();
int targetLen = WideCharToMultiByte(CP_UTF8, 0, source, -1, nullptr, 0, nullptr, nullptr);
if (targetLen == 0)
return std::string();
char* szTemp = 0;
if (targetLen >= DEFAULT_CHAR_BUF_SIZE)
szTemp = new char[targetLen];
else
szTemp = DEFAULT_CHAR_BUF;
WideCharToMultiByte(CP_UTF8, 0, source, -1, szTemp, targetLen, nullptr, nullptr);
return std::string(szTemp);
}
std::wstring convertUtf8StringToWide(const char* source)
{
const static int DEFAULT_WCHAR_BUF_SIZE = 1024;
wchar_t DEFAULT_WCHAR_BUF[DEFAULT_WCHAR_BUF_SIZE] = { 0 };
if (source == nullptr || source[0] == '\0')
return std::wstring();
int targetLen = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, source, -1, nullptr, 0);
if (targetLen == 0)
return std::wstring();
wchar_t* wszTemp = 0;
if (targetLen >= DEFAULT_WCHAR_BUF_SIZE)
wszTemp = new wchar_t[targetLen];
else
wszTemp = DEFAULT_WCHAR_BUF;
int result = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, source, -1, wszTemp, targetLen);
return std::wstring(wszTemp);
}
uint8_t* readFileToBuffer(const char* filename, int64_t& outSize)
{
FILE* file = nullptr;