diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 91bb953e..0404533a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -154,11 +154,7 @@ endif() target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR}) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstudxml) - -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0") - target_compile_definitions(xlnt PRIVATE UTFCPP=1) - target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp) -endif() +target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp) if(MSVC) set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP") diff --git a/source/detail/unicode.cpp b/source/detail/unicode.cpp index 722b6800..84f07c79 100644 --- a/source/detail/unicode.cpp +++ b/source/detail/unicode.cpp @@ -21,55 +21,18 @@ // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file -#include -#include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wsign-conversion" +#include +#pragma clang diagnostic pop #include -#ifdef UTFCPP -#include -#else -#include -#endif - namespace xlnt { namespace detail { -#ifndef UTFCPP -#ifdef _MSC_VER -std::u16string utf8_to_utf16(const std::string &utf8_string) -{ - // use wchar_t instead of char16_t on Windows because of a bug in MSVC - // error LNK2001: unresolved external symbol std::codecvt::id - // https://connect.microsoft.com/VisualStudio/Feedback/Details/1403302 - auto converted = std::wstring_convert, - wchar_t>{}.from_bytes(utf8_string); - return std::u16string(converted.begin(), converted.end()); -} - -std::string utf16_to_utf8(const std::u16string &utf16_string) -{ - std::wstring utf16_wstring(utf16_string.begin(), utf16_string.end()); - // use wchar_t instead of char16_t on Windows because of a bug in MSVC - // error LNK2001: unresolved external symbol std::codecvt::id - // https://connect.microsoft.com/VisualStudio/Feedback/Details/1403302 - return std::wstring_convert, - wchar_t>{}.to_bytes(utf16_wstring); -} -#else -std::u16string utf8_to_utf16(const std::string &utf8_string) -{ - return std::wstring_convert, - char16_t>{}.from_bytes(utf8_string); -} - -std::string utf16_to_utf8(const std::u16string &utf16_string) -{ - return std::wstring_convert, - char16_t>{}.to_bytes(utf16_string); -} -#endif -#else std::u16string utf8_to_utf16(const std::string &utf8_string) { std::u16string result; @@ -85,7 +48,6 @@ std::string utf16_to_utf8(const std::u16string &utf16_string) return result; } -#endif std::string latin1_to_utf8(const std::string &latin1) {