fix: handle UTF-8 file paths on Windows (#2145)

This commit is contained in:
therealshulgin authored and GitHub committed 2026-10-17 00:50:42 +08:00
1 parent 8c442fb0ad
commit 2f016e8e30
9 files changed
+100 -82

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
#include "routes.h"
#include <filesystem>
#include <fstream>
#include <iterator>
@@ -7,7 +8,7 @@ void register_index_endpoints(httplib::Server& svr, const SDSvrParams& svr_param
const std::string serve_html_path = svr_params.serve_html_path;
svr.Get("/", [serve_html_path, index_html](const httplib::Request&, httplib::Response& res) {
if (!serve_html_path.empty()) {
std::ifstream file(serve_html_path);
std::ifstream file(std::filesystem::u8path(serve_html_path));
if (file) {
std::string content((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
res.set_content(content, "text/html");