From de711b6e7087070150ac593cca0aef28f0ab8bd6 Mon Sep 17 00:00:00 2001 From: Jackarain Date: Thu, 15 Aug 2024 15:59:25 +0800 Subject: [PATCH] Remove std::codecvt and std::codecvt deprecated since C++20 --- proxy/include/proxy/strutil.hpp | 55 --------------------------------- 1 file changed, 55 deletions(-) diff --git a/proxy/include/proxy/strutil.hpp b/proxy/include/proxy/strutil.hpp index 8d894212b..63f0a41b9 100644 --- a/proxy/include/proxy/strutil.hpp +++ b/proxy/include/proxy/strutil.hpp @@ -1157,61 +1157,6 @@ namespace strutil return true; } - inline std::optional utf8_utf16(std::u8string_view utf8) - { - const char8_t* first = &utf8[0]; - const char8_t* last = first + utf8.size(); - - std::u16string result(utf8.size(), char16_t{ 0 }); - char16_t* dest = &result[0]; - char16_t* next = nullptr; - - using codecvt_type = std::codecvt; - - codecvt_type* cvt = new codecvt_type; - - // manages reference to codecvt facet to free memory. - std::locale loc; - loc = std::locale(loc, cvt); - - codecvt_type::state_type state{}; - - auto ret = cvt->in( - state, first, last, first, dest, dest + result.size(), next); - if (ret != codecvt_type::ok) - return {}; - - result.resize(static_cast(next - dest)); - return result; - } - - inline std::optional utf16_utf8(std::u16string_view utf16) - { - const char16_t* first = &utf16[0]; - const char16_t* last = first + utf16.size(); - - std::u8string result((utf16.size() + 1) * 6, char{ 0 }); - char8_t* dest = &result[0]; - char8_t* next = nullptr; - - using codecvt_type = std::codecvt; - - codecvt_type* cvt = new codecvt_type; - // manages reference to codecvt facet to free memory. - std::locale loc; - loc = std::locale(loc, cvt); - - codecvt_type::state_type state{}; - - auto ret = cvt->out( - state, first, last, first, dest, dest + result.size(), next); - if (ret != codecvt_type::ok) - return {}; - - result.resize(static_cast(next - dest)); - return result; - } - inline std::optional string_wide(std::string_view src) { const char* first = src.data();