From 94452b4a7acb3d637f7eaa5daf73d68005c990c9 Mon Sep 17 00:00:00 2001 From: Cristian Ritter Date: Wed, 11 Jun 2025 18:21:58 -0300 Subject: [PATCH] change deprecated wstring_convert to Boost.Locale and fix #6779 issue --- src/ifcparse/IfcCharacterDecoder.cpp | 41 ++-------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/src/ifcparse/IfcCharacterDecoder.cpp b/src/ifcparse/IfcCharacterDecoder.cpp index e5baad8639..0935b70e6c 100644 --- a/src/ifcparse/IfcCharacterDecoder.cpp +++ b/src/ifcparse/IfcCharacterDecoder.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #define FIRST_SOLIDUS (1 << 1) #define PAGE (1 << 2) @@ -417,45 +418,9 @@ std::u32string::value_type IfcUtil::convert_codepage(int codepage, int character } std::string IfcUtil::convert_utf8(const std::u32string& string) { - return std::wstring_convert, char32_t>().to_bytes(string); + return boost::locale::conv::utf_to_utf(string); } -#ifdef _MSC_VER - -// bug in msvc 2015 and 2017, unsure if fixed in later versions -// edit: maybe not bug actually, but a gap in the standard? - std::u32string IfcUtil::convert_utf8(const std::string& s) { - bool is_ascii = true; - for (char c : s) { - if (static_cast(c) >= 128) { - is_ascii = false; - break; - } - } - if (is_ascii) { - return std::u32string(s.begin(), s.end()); - } else { - auto converted = std::wstring_convert, int32_t>().from_bytes(s); - return std::u32string(reinterpret_cast(converted.data())); - } + return boost::locale::conv::utf_to_utf(s); } - -#else - -std::u32string IfcUtil::convert_utf8(const std::string& s) { - bool is_ascii = true; - for (char c : s) { - if (static_cast(c) >= 128) { - is_ascii = false; - break; - } - } - if (is_ascii) { - return std::u32string(s.begin(), s.end()); - } else { - return std::wstring_convert, std::u32string::value_type>().from_bytes(s); - } -} - -#endif