string: add variants for char16_t/char32_t strings

char16_t is not exactly the wchar_t on Windows. char32_t is not exactly
the wchar_t on POSIX. Rather than selecting the appropriate variant,
polymorphism picked the template implementation of strncmp, strcpy and
strncpy. The one that does not convert UTF16 surrogate pairs against
their UTF32 representation.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
2025-01-13 10:56:38 +01:00
parent a7543cf9ab
commit 2674bb0e32
2 changed files with 122 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
SPDX-License-Identifier: MIT
Copyright © 2023-2025 Amebis
*/
@@ -16,7 +16,7 @@ namespace UnitTests
{
stdex::utf32_t tmp[0x100];
stdex::strncpy(tmp, u"This is a 🐔Test🐮.");
Assert::AreEqual(reinterpret_cast<const stdex::utf32_t*>(U"This is a 🐔Test🐮."), tmp);
Assert::IsTrue(stdex::strcmp(U"This is a 🐔Test🐮.", tmp) == 0);
}
void string::sprintf()