From 6796ef2bc09a5c991727816eda51e43eef0d01d6 Mon Sep 17 00:00:00 2001
From: "kinly.lei" <kinly.lei@gmail.com>
Date: Wed, 3 Jul 2024 20:08:20 +0800
Subject: [PATCH 1/2] fixed: 1. added compile version check to support Chinese
 path xml-file parsing 2. cmake add msvc /utf-8 options

---
 CMakeLists.txt      |  2 ++
 src/xml_parsing.cpp | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b6d1ebaa..fa551b103 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,8 @@ else()
     include(cmake/conan_build.cmake)
 endif()
 
+add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
+add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
 
 #############################################################
 # LIBRARY
diff --git a/src/xml_parsing.cpp b/src/xml_parsing.cpp
index b74b1ddb4..2e950e4d9 100644
--- a/src/xml_parsing.cpp
+++ b/src/xml_parsing.cpp
@@ -19,6 +19,12 @@
 #include <string>
 #include <typeindex>
 
+#if defined(_MSVC_LANG) && !defined(__clang__)
+#define __bt_cplusplus (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
+#else
+#define __bt_cplusplus __cplusplus
+#endif
+
 #if defined(__linux) || defined(__linux__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wattributes"
@@ -254,7 +260,12 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes)
       break;
     }
 
-    std::filesystem::path file_path(incl_node->Attribute("path"));
+#if __bt_cplusplus >= 202002L
+    auto file_path(std::filesystem::path(incl_node->Attribute("path")));
+#else
+    auto file_path(std::filesystem::u8path(incl_node->Attribute("path")));
+#endif
+
     const char* ros_pkg_relative_path = incl_node->Attribute("ros_pkg");
 
     if(ros_pkg_relative_path)

From 50e5eef44de25437f4093c9710a59dff3718a598 Mon Sep 17 00:00:00 2001
From: "kinly.lei" <kinly.lei@gmail.com>
Date: Tue, 23 Jul 2024 10:14:56 +0800
Subject: [PATCH 2/2] change cmake /utf-8 option add mode

---
 CMakeLists.txt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa551b103..16993735a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,9 +74,6 @@ else()
     include(cmake/conan_build.cmake)
 endif()
 
-add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
-add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
-
 #############################################################
 # LIBRARY
 
@@ -189,6 +186,7 @@ target_compile_definitions(${BTCPP_LIBRARY} PUBLIC BTCPP_LIBRARY_VERSION="${CMAK
 target_compile_features(${BTCPP_LIBRARY} PUBLIC cxx_std_17)
 
 if(MSVC)
+	target_compile_options(${BTCPP_LIBRARY} PRIVATE "/source-charset:utf-8")
 else()
     target_compile_options(${BTCPP_LIBRARY} PRIVATE -Wall -Wextra)
 endif()