diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 2a99f5b..708df68 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -7440,28 +7440,16 @@ namespace pugi } #ifndef PUGIXML_NO_STL - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const wchar_t* str) + PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const pugi::wstring_view& str) { - assert(str); - - return impl::as_utf8_impl(str, impl::strlength_wide(str)); + return impl::as_utf8_impl(str.data(), str.length()); } - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const std::basic_string& str) + PUGI__FN std::wstring PUGIXML_FUNCTION as_wide(const pugi::string_view& str) { - return impl::as_utf8_impl(str.c_str(), str.size()); - } + assert(str.data()); - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const char* str) - { - assert(str); - - return impl::as_wide_impl(str, strlen(str)); - } - - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const std::string& str) - { - return impl::as_wide_impl(str.c_str(), str.size()); + return impl::as_wide_impl(str.data(), str.length()); } #endif diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 080f61f..bc5d62c 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -1561,12 +1561,10 @@ namespace pugi #ifndef PUGIXML_NO_STL // Convert wide string to UTF8 - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const std::basic_string, std::allocator >& str); + std::string PUGIXML_FUNCTION as_utf8(const pugi::wstring_view& str); // Convert UTF8 to wide string - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const char* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const std::basic_string, std::allocator >& str); + std::wstring PUGIXML_FUNCTION as_wide(const pugi::string_view& str); #endif // Memory allocation function interface; returns pointer to allocated memory or NULL on failure