#include "FaceApp.h" std::wstring ReadUTF8File(const std::string& filePath) { std::ifstream file(filePath, std::ios::binary); if (!file.is_open()) { throw std::runtime_error("无法打开UTF-8文件: " + filePath); } // 读取文件所有内容 std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); file.close(); // 将UTF-8字符串转换为宽字符串 return AppBase::UTF8ToWideString(content); } std::wstring ReadFileWithChinesePath(const std::wstring& filePath) { // 使用二进制模式打开文件 std::ifstream file(filePath, std::ios::binary); if (!file.is_open()) { std::wcout << L"无法打开文件: " << filePath << std::endl; return L""; } // 读取文件内容到std::string std::string context; file.seekg(0, std::ios::end); context.resize(file.tellg()); file.seekg(0, std::ios::beg); file.read(&context[0], context.size()); file.close(); return AppBase::UTF8ToWideString(context); } int main() { //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 = "action24"; for (int i = 0; i < 25; ++i) { if (i < 10) { motion.png_names.push_back("00000" + std::to_string(i) + ".png"); } else { motion.png_names.push_back("0000" + std::to_string(i) + ".png"); } } # init_arg.motion = motion; init_arg.action_fps = 10; init_arg.zoom = 1.5f; string json_str = json(init_arg).dump(); FaceApp app; app.SetInitArg(json_str.c_str()); app.initVulkan(); app._running = true; app.mainLoop(); //try { // app.mainLoop(); //} catch (const std::exception& e) { // std::cerr << e.what() << std::endl; // return EXIT_FAILURE; //} app.cleanup(); return EXIT_SUCCESS; }