Skip to content

Commit 6796ef2

Browse files
committed
fixed: 1. added compile version check to support Chinese path xml-file parsing 2. cmake add msvc /utf-8 options
1 parent 2a8a226 commit 6796ef2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ else()
7474
include(cmake/conan_build.cmake)
7575
endif()
7676

77+
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
78+
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
7779

7880
#############################################################
7981
# LIBRARY

src/xml_parsing.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#include <string>
2020
#include <typeindex>
2121

22+
#if defined(_MSVC_LANG) && !defined(__clang__)
23+
#define __bt_cplusplus (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
24+
#else
25+
#define __bt_cplusplus __cplusplus
26+
#endif
27+
2228
#if defined(__linux) || defined(__linux__)
2329
#pragma GCC diagnostic push
2430
#pragma GCC diagnostic ignored "-Wattributes"
@@ -254,7 +260,12 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes)
254260
break;
255261
}
256262

257-
std::filesystem::path file_path(incl_node->Attribute("path"));
263+
#if __bt_cplusplus >= 202002L
264+
auto file_path(std::filesystem::path(incl_node->Attribute("path")));
265+
#else
266+
auto file_path(std::filesystem::u8path(incl_node->Attribute("path")));
267+
#endif
268+
258269
const char* ros_pkg_relative_path = incl_node->Attribute("ros_pkg");
259270

260271
if(ros_pkg_relative_path)

0 commit comments

Comments
 (0)