Skip to content

Commit

Permalink
fixed: support utf-8 path xml-file (#845)
Browse files Browse the repository at this point in the history
* fixed: 1. added compile version check to support Chinese path xml-file parsing 2. cmake add msvc /utf-8 options

* change cmake /utf-8 option add mode
  • Loading branch information
kinly authored Aug 28, 2024
1 parent 89dbbb7 commit 4f66447
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ else()
include(cmake/conan_build.cmake)
endif()


#############################################################
# LIBRARY

Expand Down Expand Up @@ -187,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()
Expand Down
13 changes: 12 additions & 1 deletion src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4f66447

Please sign in to comment.