From c6d9ddc58f3f1127c39b1aeaece83362323686b3 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 17 May 2026 14:22:44 +0200 Subject: add overloads for u8string --- include/winapi/utf8.hpp | 3 +++ src/convert.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/winapi/utf8.hpp b/include/winapi/utf8.hpp index c6bb03a..2e87f75 100644 --- a/include/winapi/utf8.hpp +++ b/include/winapi/utf8.hpp @@ -22,6 +22,9 @@ static_assert(sizeof(wchar_t) == 2, "This is Windows, right?"); /** Convert UTF-8 string to UTF-16. */ std::wstring widen(const std::string&); +#ifdef __cpp_lib_char8_t +std::wstring widen(const std::u8string&); +#endif /** * Convert UTF-8 string to UTF-16. diff --git a/src/convert.cpp b/src/convert.cpp index 4ccc3a0..c0a8e98 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -100,6 +100,12 @@ std::wstring widen(const std::string& src) { return widen(src.c_str(), src.size()); } +#ifdef __cpp_lib_char8_t +std::wstring widen(const std::u8string& src) { + return widen(src.c_str(), src.size()); +} +#endif + std::wstring widen(const void* src, std::size_t in_nb) { const DWORD flags = MB_ERR_INVALID_CHARS; -- cgit v1.3