10using namespace Microsoft::VisualStudio::CppUnitTestFramework;
22 stdex::str2wstr(
"This is a test.", stdex::charset_id::utf8).c_str());
24 L
"Th\u00ed\u0161 i\u22c5 a te\u0073\u0304t. 😀😅",
25 stdex::str2wstr(
"Thíš i⋅ a tes̄t. 😀😅", stdex::charset_id::utf8).c_str());
28 for (
size_t i = 0; i < 2000; i++) {
32 Assert::AreEqual(dst.c_str(), stdex::str2wstr(src, stdex::charset_id::utf8).c_str());
35 stdex::str2wstr(
"test", 0, stdex::charset_id::utf8).c_str());
38 stdex::str2wstr(
nullptr, 0, stdex::charset_id::utf8).c_str());
45 stdex::wstr2str(L
"This is a test.", stdex::charset_id::utf8).c_str());
47 "Th\xc3\xad\xc5\xa1 i\xe2\x8b\x85 a tes\xcc\x84t. \xf0\x9f\x98\x80\xf0\x9f\x98\x85",
48 stdex::wstr2str(L
"Thíš i⋅ a tes̄t. 😀😅", stdex::charset_id::utf8).c_str());
51 for (
size_t i = 0; i < 2000; i++) {
55 Assert::AreEqual(dst.c_str(), stdex::wstr2str(src, stdex::charset_id::utf8).c_str());
58 stdex::wstr2str(L
"test", 0, stdex::charset_id::utf8).c_str());
61 stdex::wstr2str(
nullptr, 0, stdex::charset_id::utf8).c_str());
64 TEST_METHOD(charset_encoder)
70 win1250_to_utf8.convert(
"This is a test.").c_str());
73 win1250_to_utf8.convert(
"Th\xed\x9a i\xb7 a te\xbat.").c_str());
75 for (
size_t i = 0; i < 1000; i++) {
76 src +=
"V ko\x9eu\x9a\xe8ku zlobnega mizarja stopiclja fant in kli\xe8" "e 0123456789.\r\n";
77 dst +=
"V kožuščku zlobnega mizarja stopiclja fant in kliče 0123456789.\r\n";
79 Assert::AreEqual(dst.c_str(), win1250_to_utf8.convert(src).c_str());
82 win1250_to_utf8.convert(
"test", 0).c_str());
85 win1250_to_utf8.convert(
nullptr, 0).c_str());
Encoding converter context.
Definition unicode.hpp:56