diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/common/string_util.cpp | 14 |
2 files changed, 2 insertions, 14 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index bfd11e76d..263c457cd 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -206,6 +206,8 @@ if (MSVC) | |||
| 206 | else() | 206 | else() |
| 207 | target_compile_options(common PRIVATE | 207 | target_compile_options(common PRIVATE |
| 208 | -Werror | 208 | -Werror |
| 209 | |||
| 210 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> | ||
| 209 | ) | 211 | ) |
| 210 | endif() | 212 | endif() |
| 211 | 213 | ||
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 4cba2aaa4..7b614ad89 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -141,27 +141,13 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st | |||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | std::string UTF16ToUTF8(const std::u16string& input) { | 143 | std::string UTF16ToUTF8(const std::u16string& input) { |
| 144 | #ifdef _MSC_VER | ||
| 145 | // Workaround for missing char16_t/char32_t instantiations in MSVC2017 | ||
| 146 | std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; | ||
| 147 | std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend()); | ||
| 148 | return convert.to_bytes(tmp_buffer); | ||
| 149 | #else | ||
| 150 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; | 144 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |
| 151 | return convert.to_bytes(input); | 145 | return convert.to_bytes(input); |
| 152 | #endif | ||
| 153 | } | 146 | } |
| 154 | 147 | ||
| 155 | std::u16string UTF8ToUTF16(const std::string& input) { | 148 | std::u16string UTF8ToUTF16(const std::string& input) { |
| 156 | #ifdef _MSC_VER | ||
| 157 | // Workaround for missing char16_t/char32_t instantiations in MSVC2017 | ||
| 158 | std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; | ||
| 159 | auto tmp_buffer = convert.from_bytes(input); | ||
| 160 | return std::u16string(tmp_buffer.cbegin(), tmp_buffer.cend()); | ||
| 161 | #else | ||
| 162 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; | 149 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |
| 163 | return convert.from_bytes(input); | 150 | return convert.from_bytes(input); |
| 164 | #endif | ||
| 165 | } | 151 | } |
| 166 | 152 | ||
| 167 | #ifdef _WIN32 | 153 | #ifdef _WIN32 |