From 68c45ee5bb9c998923f7a8ce7857128803dbe93a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 27 Sep 2021 16:44:30 +0300 Subject: add a std::u16string overload --- include/winapi/utf8.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/winapi/utf8.hpp') diff --git a/include/winapi/utf8.hpp b/include/winapi/utf8.hpp index 9259df6..c6bb03a 100644 --- a/include/winapi/utf8.hpp +++ b/include/winapi/utf8.hpp @@ -17,6 +17,9 @@ namespace winapi { +/* sizeof(wchar_t) == 4 on Linux, we don't care about that. */ +static_assert(sizeof(wchar_t) == 2, "This is Windows, right?"); + /** Convert UTF-8 string to UTF-16. */ std::wstring widen(const std::string&); @@ -39,6 +42,9 @@ std::wstring widen(const std::vector& src) { /** Convert UTF-16 string to UTF-8. */ std::string narrow(const std::wstring&); +/** Convert UTF-16 string to UTF-8. */ +std::string narrow(const std::u16string&); + /** * Convert UTF-16 string to UTF-8. * \param src Memory address of a UTF-16 string. -- cgit v1.2.3