android 平台跑通中文路径

This commit is contained in:
xsl
2025-10-28 22:24:24 +08:00
parent 1dfc63543f
commit 13357ab256
20 changed files with 149 additions and 39 deletions
+12 -27
View File
@@ -1,23 +1,8 @@
#include "FaceApp.h"
#include <windows.h>
std::wstring UTF8ToWideString(const std::string& utf8str)
{
if (utf8str.empty()) return L"";
int wideLen = MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(),
-1, nullptr, 0);
if (wideLen == 0) {
throw std::runtime_error("UTF-8转换失败");
}
std::vector<wchar_t> buffer(wideLen);
MultiByteToWideChar(CP_UTF8, 0, utf8str.c_str(), -1,
buffer.data(), wideLen);
return std::wstring(buffer.data());
}
std::wstring ReadUTF8File(const std::string& filePath)
{
@@ -32,7 +17,7 @@ std::wstring ReadUTF8File(const std::string& filePath)
file.close();
// 将UTF-8字符串转换为宽字符串
return UTF8ToWideString(content);
return AppBase::UTF8ToWideString(content);
}
@@ -51,23 +36,23 @@ std::wstring ReadFileWithChinesePath(const std::wstring& filePath) {
file.seekg(0, std::ios::beg);
file.read(&context[0], context.size());
file.close();
return UTF8ToWideString(context);
return AppBase::UTF8ToWideString(context);
}
int main() {
std::string path = "chinese.txt";
std::wstring chinese = ReadUTF8File(path);
std::wstring chinese_path = UTF8ToWideString("d:/测试目录/中文文件.txt");
std::wstring content = ReadFileWithChinesePath(chinese_path);
//std::string path = "chinese.txt";
//std::wstring chinese = ReadUTF8File(path);
//std::wstring chinese_path = AppBase::UTF8ToWideString("d:/测试目录/中文文件.txt");
//std::wstring content = ReadFileWithChinesePath(chinese_path);
InitArg init_arg;
Motion motion;
motion.type = "bottom_makeup";
motion.technique = "base_makeup";
motion.step = "press2";
motion.show_type = "direction";
motion.type = "底妆";
motion.technique = "基础上妆";
motion.step = "2按压";
motion.show_type = "方向示意图";
motion.png_name = "test";
motion.png_num = 1;
#