From 6360fb80be4f6c6f392c13d2e6c55297965c24a6 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Fri, 25 Oct 2024 09:45:59 +0800 Subject: [PATCH] FIX:mtl name use utf-8 encoding jira: none Change-Id: I9a90344ac97f44445d3330c6734fac1372a1350e --- src/libslic3r/Format/OBJ.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Format/OBJ.cpp b/src/libslic3r/Format/OBJ.cpp index 9a90c522e..634d29d84 100644 --- a/src/libslic3r/Format/OBJ.cpp +++ b/src/libslic3r/Format/OBJ.cpp @@ -8,6 +8,7 @@ #include #include +#include #ifdef _WIN32 #define DIR_SEPARATOR '\\' @@ -45,16 +46,20 @@ bool load_obj(const char *path, TriangleMesh *meshptr, ObjInfo& obj_info, std::s continue; } exist_mtl = true; - bool mtl_name_is_path = false; - boost::filesystem::path mtl_abs_path(mtl_name); + bool mtl_name_is_path = false; + std::wstring wide_mtl_name = boost::locale::conv::to_utf(mtl_name, "UTF-8"); + if (boost::istarts_with(wide_mtl_name,"./")){ + boost::replace_first(wide_mtl_name, "./", ""); + } + boost::filesystem::path mtl_abs_path(wide_mtl_name); if (boost::filesystem::exists(mtl_abs_path)) { mtl_name_is_path = true; } boost::filesystem::path mtl_path; if (!mtl_name_is_path) { boost::filesystem::path full_path(path); - std::string dir = full_path.parent_path().string(); - auto mtl_file = dir + "/" + mtl_name; + auto dir = full_path.parent_path().wstring(); + auto mtl_file = dir + L"/" + wide_mtl_name; boost::filesystem::path temp_mtl_path(mtl_file); mtl_path = temp_mtl_path; }