From 24ec1d5ba85503599fd301aa8cd56ee65651ab0b Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 12 Feb 2021 18:12:51 +0100 Subject: Added support for char and wchar_t --- src/test-unicode.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/test-unicode.cpp b/src/test-unicode.cpp index 692dfac..99a8f99 100644 --- a/src/test-unicode.cpp +++ b/src/test-unicode.cpp @@ -334,6 +334,23 @@ BOOST_AUTO_TEST_CASE(convert) BOOST_CHECK((unicode::convert("abc")) == std::u16string{u"abc"}); BOOST_CHECK((unicode::convert(U"abc")) == std::u16string{u"abc"}); + + BOOST_CHECK((unicode::convert(u8"äöü")) == std::u32string{U"äöü"}); + +#ifdef _WIN32 + BOOST_CHECK(sizeof(wchar_t) == 2); +#else // Unix like + BOOST_CHECK(sizeof(wchar_t) == 4); +#endif + + // For the following checks, wchar_t size and encoding is system dependent: + // Windows: UTF-16 + // Linux: UTF-32 + BOOST_CHECK((unicode::convert(u8"äöü")) == std::wstring{L"äöü"}); + BOOST_CHECK((unicode::convert(u8"\u732b")) == std::wstring{L"\u732b"}); + BOOST_CHECK((unicode::convert(u8"\U0001F63A")) == std::wstring{L"\U0001F63A"}); + BOOST_CHECK((unicode::convert(L"\U0001F63A")) == std::u32string{U"\U0001F63A"}); + BOOST_CHECK((unicode::convert(L"\U0001F63A")) == std::string{u8"\U0001F63A"}); } BOOST_AUTO_TEST_CASE(is_valid_utf) -- cgit v1.2.3