unicode: extend conversion with reusable charset_encoder

Windows takes care of internal converter state in MultiByteToWideChar
and WideCharToMultiByte and keeps them thread-safe. On other platforms,
iconv requires user to setup and keep converter state for thread-safe
conversions. This sounds time consuming for every string conversion,
therefore the concept of string converter (or converter state) has been
extended to Windows too, allowing uniform client code. On Windows, using
charset_encoder has no performance benefit, where on Linux and macOS,
there should be. To be measured...

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman
2023-09-14 12:28:05 +02:00
parent 66f8a6c3b7
commit 13703b1747
3 changed files with 360 additions and 62 deletions

View File

@@ -28,6 +28,7 @@ int main(int argc, const char * argv[])
UnitTests::stream::open_close();
UnitTests::unicode::str2wstr();
UnitTests::unicode::wstr2str();
UnitTests::unicode::charset_encoder();
std::cout << "PASS\n";
return 0;
}