3#include <winpr/wtypes.h>
5#include <winpr/assert.h>
6#include <winpr/error.h>
7#include <winpr/print.h>
8#include <winpr/windows.h>
10#if defined(BUILD_TESTING_INTERNAL)
11#include "../unicode.h"
14#define TESTCASE_BUFFER_SIZE 8192
17#define MIN(x, y) (((x) < (y)) ? (x) : (y))
30static const testcase_t unit_testcases[] = {
31 {
"foo", 3, (
const WCHAR*)
"f\x00o\x00o\x00\x00\x00", 3 },
32 {
"foo", 4, (
const WCHAR*)
"f\x00o\x00o\x00\x00\x00", 4 },
33 {
"βπ
ΔΚ₯κ£Έπa", 19,
34 (
const WCHAR*)
"\x0a\x27\x3c\xd8\x85\xdf\x19\x01\xa5\x02\xf8\xa8\x05\xd8\xca\xdd\x61\x00\x00"
39static void create_prefix(
char* prefix,
size_t prefixlen,
size_t buffersize, SSIZE_T rc,
40 SSIZE_T inputlen,
const testcase_t* test,
const char* fkt,
size_t line)
42 (void)_snprintf(prefix, prefixlen,
43 "[%s:%" PRIuz
"] '%s' [utf8: %" PRIuz
", utf16: %" PRIuz
"] buffersize: %" PRIuz
44 ", rc: %" PRIdz
", inputlen: %" PRIdz
":: ",
45 fkt, line, test->utf8, test->utf8len, test->utf16len, buffersize, rc, inputlen);
48static BOOL check_short_buffer(
const char* prefix,
int rc,
size_t buffersize,
49 const testcase_t* test, BOOL utf8)
51 if ((rc > 0) && ((
size_t)rc <= buffersize))
54 size_t len = test->utf8len;
61 "%s length does not match buffersize: %" PRId32
" != %" PRIuz
62 ",but is large enough to hold result\n",
63 prefix, rc, buffersize);
66 const DWORD err = GetLastError();
67 if (err != ERROR_INSUFFICIENT_BUFFER)
71 "%s length does not match buffersize: %" PRId32
" != %" PRIuz
72 ", unexpected GetLastError() 0x%08" PRIx32
"\n",
73 prefix, rc, buffersize, err);
80#define compare_utf16(what, buffersize, rc, inputlen, test) \
81 compare_utf16_int((what), (buffersize), (rc), (inputlen), (test), __func__, __LINE__)
82static BOOL compare_utf16_int(
const WCHAR* what,
size_t buffersize, SSIZE_T rc, SSIZE_T inputlen,
83 const testcase_t* test,
const char* fkt,
size_t line)
85 char prefix[8192] = WINPR_C_ARRAY_INIT;
86 create_prefix(prefix, ARRAYSIZE(prefix), buffersize, rc, inputlen, test, fkt, line);
88 WINPR_ASSERT(what || (buffersize == 0));
91 const size_t welen = _wcsnlen(test->utf16, test->utf16len);
92 if (buffersize > welen)
94 if ((rc < 0) || ((
size_t)rc != welen))
97 "%s length does not match expectation: %" PRIdz
" != %" PRIuz
"\n",
104 if (!check_short_buffer(prefix, WINPR_ASSERTING_INT_CAST(SSIZE_T, rc), buffersize, test,
109 if ((rc > 0) && (buffersize > (size_t)rc))
111 const size_t wlen = _wcsnlen(what, buffersize);
112 if ((rc < 0) || (wlen > (
size_t)rc))
114 (void)fprintf(stderr,
"%s length does not match wcslen: %" PRIdz
" < %" PRIuz
"\n",
122 if (memcmp(test->utf16, what, rc *
sizeof(WCHAR)) != 0)
124 (void)fprintf(stderr,
"%s contents does not match expectations: TODO '%s' != '%s'\n",
125 prefix, test->utf8, test->utf8);
130 printf(
"%s success\n", prefix);
135#define compare_utf8(what, buffersize, rc, inputlen, test) \
136 compare_utf8_int((what), (buffersize), (rc), (inputlen), (test), __func__, __LINE__)
137static BOOL compare_utf8_int(
const char* what,
size_t buffersize, SSIZE_T rc, SSIZE_T inputlen,
138 const testcase_t* test,
const char* fkt,
size_t line)
140 char prefix[8192] = WINPR_C_ARRAY_INIT;
141 create_prefix(prefix, ARRAYSIZE(prefix), buffersize, rc, inputlen, test, fkt, line);
143 WINPR_ASSERT(what || (buffersize == 0));
146 const size_t slen = strnlen(test->utf8, test->utf8len);
147 if (buffersize > slen)
149 if ((rc < 0) || ((
size_t)rc != slen))
151 (void)fprintf(stderr,
152 "%s length does not match expectation: %" PRIdz
" != %" PRIuz
"\n",
159 if (!check_short_buffer(prefix, WINPR_ASSERTING_INT_CAST(SSIZE_T, rc), buffersize, test,
164 if ((rc > 0) && (buffersize > (size_t)rc))
166 const size_t wlen = strnlen(what, buffersize);
167 if (wlen != (
size_t)rc)
169 (void)fprintf(stderr,
"%s length does not match strnlen: %" PRIdz
" != %" PRIuz
"\n",
177 if (memcmp(test->utf8, what, rc) != 0)
179 (void)fprintf(stderr,
"%s contents does not match expectations: '%s' != '%s'\n", prefix,
185 printf(
"%s success\n", prefix);
190static BOOL test_convert_to_utf16(
const testcase_t* test)
192 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
193 test->utf16len - 1 };
194 const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
196 const SSIZE_T rc2 = ConvertUtf8ToWChar(test->utf8,
nullptr, 0);
197 const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
198 if ((rc2 < 0) || ((
size_t)rc2 != wlen))
200 char prefix[8192] = WINPR_C_ARRAY_INIT;
201 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
202 (void)fprintf(stderr,
203 "%s ConvertUtf8ToWChar(%s, nullptr, 0) expected %" PRIuz
", got %" PRIdz
"\n",
204 prefix, test->utf8, wlen, rc2);
207 for (
size_t x = 0; x < max; x++)
209 WCHAR buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
210 const SSIZE_T rc = ConvertUtf8ToWChar(test->utf8, buffer, len[x]);
211 if (!compare_utf16(buffer, len[x], rc, -1, test))
218static BOOL test_convert_to_utf16_n(
const testcase_t* test)
220 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
221 test->utf16len - 1 };
222 const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
224 const SSIZE_T rc2 = ConvertUtf8NToWChar(test->utf8, test->utf8len,
nullptr, 0);
225 const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
226 if ((rc2 < 0) || ((
size_t)rc2 != wlen))
228 char prefix[8192] = WINPR_C_ARRAY_INIT;
229 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2,
230 WINPR_ASSERTING_INT_CAST(SSIZE_T, test->utf8len), test, __func__, __LINE__);
231 (void)fprintf(stderr,
232 "%s ConvertUtf8NToWChar(%s, %" PRIuz
", nullptr, 0) expected %" PRIuz
233 ", got %" PRIdz
"\n",
234 prefix, test->utf8, test->utf8len, wlen, rc2);
238 for (
size_t x = 0; x < max; x++)
240 const size_t ilen[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
242 const size_t imax = test->utf8len > 0 ? ARRAYSIZE(ilen) : ARRAYSIZE(ilen) - 1;
244 for (
size_t y = 0; y < imax; y++)
246 WCHAR buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
247 SSIZE_T rc = ConvertUtf8NToWChar(test->utf8, ilen[x], buffer, len[x]);
248 if (!compare_utf16(buffer, len[x], rc, ilen[x], test))
255static BOOL test_convert_to_utf8(
const testcase_t* test)
257 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
259 const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
261 const SSIZE_T rc2 = ConvertWCharToUtf8(test->utf16,
nullptr, 0);
262 const size_t wlen = strnlen(test->utf8, test->utf8len);
263 if ((rc2 < 0) || ((
size_t)rc2 != wlen))
265 char prefix[8192] = WINPR_C_ARRAY_INIT;
266 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
267 (void)fprintf(stderr,
268 "%s ConvertWCharToUtf8(%s, nullptr, 0) expected %" PRIuz
", got %" PRIdz
"\n",
269 prefix, test->utf8, wlen, rc2);
273 for (
size_t x = 0; x < max; x++)
275 char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
276 SSIZE_T rc = ConvertWCharToUtf8(test->utf16, buffer, len[x]);
277 if (!compare_utf8(buffer, len[x], rc, -1, test))
284static BOOL test_convert_to_utf8_n(
const testcase_t* test)
286 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
288 const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
290 const SSIZE_T rc2 = ConvertWCharNToUtf8(test->utf16, test->utf16len,
nullptr, 0);
291 const size_t wlen = strnlen(test->utf8, test->utf8len);
292 if ((rc2 < 0) || ((
size_t)rc2 != wlen))
294 char prefix[8192] = WINPR_C_ARRAY_INIT;
295 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2,
296 WINPR_ASSERTING_INT_CAST(SSIZE_T, test->utf16len), test, __func__, __LINE__);
297 (void)fprintf(stderr,
298 "%s ConvertWCharNToUtf8(%s, %" PRIuz
", nullptr, 0) expected %" PRIuz
299 ", got %" PRIdz
"\n",
300 prefix, test->utf8, test->utf16len, wlen, rc2);
304 for (
size_t x = 0; x < max; x++)
306 const size_t ilen[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
307 test->utf16len - 1 };
308 const size_t imax = test->utf16len > 0 ? ARRAYSIZE(ilen) : ARRAYSIZE(ilen) - 1;
310 for (
size_t y = 0; y < imax; y++)
312 char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
313 SSIZE_T rc = ConvertWCharNToUtf8(test->utf16, ilen[x], buffer, len[x]);
314 if (!compare_utf8(buffer, len[x], rc, ilen[x], test))
322static BOOL test_conversion(
const testcase_t* testcases,
size_t count)
324 WINPR_ASSERT(testcases || (count == 0));
325 for (
size_t x = 0; x < count; x++)
327 const testcase_t* test = &testcases[x];
329 printf(
"Running test case %" PRIuz
" [%s]\n", x, test->utf8);
330 if (!test_convert_to_utf16(test))
332 (void)fprintf(stderr,
"Test case %" PRIuz
" [%s] convert to UTF16 failed\n",
336 if (!test_convert_to_utf16_n(test))
338 (void)fprintf(stderr,
"Test case %" PRIuz
" [%s] convert to UTF16N failed\n",
342 if (!test_convert_to_utf8(test))
344 (void)fprintf(stderr,
"Test case %" PRIuz
" [%s] convert to UTF8 failed\n", test->utf8);
347 if (!test_convert_to_utf8_n(test))
349 (void)fprintf(stderr,
"Test case %" PRIuz
" [%s] convert to UTF8N failed\n",
357#if defined(WITH_WINPR_DEPRECATED)
359#define compare_win_utf16(what, buffersize, rc, inputlen, test) \
360 compare_win_utf16_int((what), (buffersize), (rc), (inputlen), (test), __func__, __LINE__)
361static BOOL compare_win_utf16_int(
const WCHAR* what,
size_t buffersize,
int rc,
int inputlen,
362 const testcase_t* test,
const char* fkt,
size_t line)
364 char prefix[8192] = WINPR_C_ARRAY_INIT;
365 create_prefix(prefix, ARRAYSIZE(prefix), buffersize, rc, inputlen, test, fkt, line);
367 WINPR_ASSERT(what || (buffersize == 0));
370 BOOL isNullTerminated = TRUE;
372 isNullTerminated = strnlen(test->utf8, inputlen) < inputlen;
373 size_t welen = _wcsnlen(test->utf16, buffersize);
374 if (isNullTerminated)
377 if (buffersize >= welen)
379 if ((inputlen >= 0) && (rc > buffersize))
381 (void)fprintf(stderr,
"%s length does not match expectation: %d > %" PRIuz
"\n", prefix,
385 else if ((inputlen < 0) && (rc != welen))
387 (void)fprintf(stderr,
"%s length does not match expectation: %d != %" PRIuz
"\n",
394 if (!check_short_buffer(prefix, rc, buffersize, test, FALSE))
398 if ((rc > 0) && (buffersize > rc))
400 size_t wlen = _wcsnlen(what, buffersize);
401 if (isNullTerminated)
403 if ((inputlen >= 0) && (buffersize < rc))
405 (void)fprintf(stderr,
"%s length does not match wcslen: %d > %" PRIuz
"\n", prefix, rc,
409 else if ((inputlen < 0) && (welen > rc))
411 (void)fprintf(stderr,
"%s length does not match wcslen: %d < %" PRIuz
"\n", prefix, rc,
417 const size_t cmp_size = MIN(rc, test->utf16len) *
sizeof(WCHAR);
418 if (memcmp(test->utf16, what, cmp_size) != 0)
420 (void)fprintf(stderr,
"%s contents does not match expectations: TODO '%s' != '%s'\n",
421 prefix, test->utf8, test->utf8);
425 printf(
"%s success\n", prefix);
430#define compare_win_utf8(what, buffersize, rc, inputlen, test) \
431 compare_win_utf8_int((what), (buffersize), (rc), (inputlen), (test), __func__, __LINE__)
432static BOOL compare_win_utf8_int(
const char* what,
size_t buffersize, SSIZE_T rc, SSIZE_T inputlen,
433 const testcase_t* test,
const char* fkt,
size_t line)
435 char prefix[8192] = WINPR_C_ARRAY_INIT;
436 create_prefix(prefix, ARRAYSIZE(prefix), buffersize, rc, inputlen, test, fkt, line);
438 WINPR_ASSERT(what || (buffersize == 0));
441 BOOL isNullTerminated = TRUE;
443 isNullTerminated = _wcsnlen(test->utf16, inputlen) < inputlen;
445 size_t slen = strnlen(test->utf8, test->utf8len);
446 if (isNullTerminated)
449 if (buffersize > slen)
451 if ((inputlen >= 0) && (rc > buffersize))
453 (void)fprintf(stderr,
"%s length does not match expectation: %" PRIdz
" > %" PRIuz
"\n",
454 prefix, rc, buffersize);
457 else if ((inputlen < 0) && (rc != slen))
459 (void)fprintf(stderr,
460 "%s length does not match expectation: %" PRIdz
" != %" PRIuz
"\n",
467 if (!check_short_buffer(prefix, rc, buffersize, test, TRUE))
471 if ((rc > 0) && (buffersize > rc))
473 size_t wlen = strnlen(what, buffersize);
474 if (isNullTerminated)
479 (void)fprintf(stderr,
"%s length does not match wcslen: %" PRIdz
" < %" PRIuz
"\n",
485 const size_t cmp_size = MIN(test->utf8len, rc);
486 if (memcmp(test->utf8, what, cmp_size) != 0)
488 (void)fprintf(stderr,
"%s contents does not match expectations: '%s' != '%s'\n", prefix,
492 printf(
"%s success\n", prefix);
498#if defined(WITH_WINPR_DEPRECATED)
499static BOOL test_win_convert_to_utf16(
const testcase_t* test)
501 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
502 test->utf16len - 1 };
503 const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
505 const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, -1,
nullptr, 0);
506 const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
509 char prefix[8192] = WINPR_C_ARRAY_INIT;
510 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
511 (void)fprintf(stderr,
512 "%s MultiByteToWideChar(CP_UTF8, 0, %s, [-1], nullptr, 0) expected %" PRIuz
514 prefix, test->utf8, wlen + 1, rc2);
517 for (
size_t x = 0; x < max; x++)
519 WCHAR buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
520 const int rc = MultiByteToWideChar(CP_UTF8, 0, test->utf8, -1, buffer, len[x]);
521 if (!compare_win_utf16(buffer, len[x], rc, -1, test))
528static BOOL test_win_convert_to_utf16_n(
const testcase_t* test)
530 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
531 test->utf16len - 1 };
532 const size_t max = test->utf16len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
534 BOOL isNullTerminated = strnlen(test->utf8, test->utf8len) < test->utf8len;
535 const int rc2 = MultiByteToWideChar(CP_UTF8, 0, test->utf8, test->utf8len,
nullptr, 0);
536 size_t wlen = _wcsnlen(test->utf16, test->utf16len);
537 if (isNullTerminated)
542 char prefix[8192] = WINPR_C_ARRAY_INIT;
543 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf8len, test, __func__, __LINE__);
544 (void)fprintf(stderr,
545 "%s MultiByteToWideChar(CP_UTF8, 0, %s, %" PRIuz
546 ", nullptr, 0) expected %" PRIuz
", got %d\n",
547 prefix, test->utf8, test->utf8len, wlen, rc2);
551 for (
size_t x = 0; x < max; x++)
553 const size_t ilen[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
555 const size_t imax = test->utf8len > 0 ? ARRAYSIZE(ilen) : ARRAYSIZE(ilen) - 1;
557 for (
size_t y = 0; y < imax; y++)
559 char mbuffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
560 WCHAR buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
561 strncpy(mbuffer, test->utf8, test->utf8len);
562 const int rc = MultiByteToWideChar(CP_UTF8, 0, mbuffer, ilen[x], buffer, len[x]);
563 if (!compare_win_utf16(buffer, len[x], rc, ilen[x], test))
571#if defined(WITH_WINPR_DEPRECATED)
572static BOOL test_win_convert_to_utf8(
const testcase_t* test)
574 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
576 const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
578 const int rc2 = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1,
nullptr, 0,
nullptr,
nullptr);
579 const size_t wlen = strnlen(test->utf8, test->utf8len) + 1;
582 char prefix[8192] = WINPR_C_ARRAY_INIT;
583 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __func__, __LINE__);
584 (void)fprintf(stderr,
585 "%s WideCharToMultiByte(CP_UTF8, 0, %s, -1, nullptr, 0, nullptr, nullptr) "
586 "expected %" PRIuz
", got %d\n",
587 prefix, test->utf8, wlen, rc2);
591 for (
size_t x = 0; x < max; x++)
593 char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
594 int rc = WideCharToMultiByte(CP_UTF8, 0, test->utf16, -1, buffer, len[x],
nullptr,
nullptr);
595 if (!compare_win_utf8(buffer, len[x], rc, -1, test))
602static BOOL test_win_convert_to_utf8_n(
const testcase_t* test)
604 const size_t len[] = { TESTCASE_BUFFER_SIZE, test->utf8len, test->utf8len + 1,
606 const size_t max = test->utf8len > 0 ? ARRAYSIZE(len) : ARRAYSIZE(len) - 1;
608 const BOOL isNullTerminated = _wcsnlen(test->utf16, test->utf16len) < test->utf16len;
610 WideCharToMultiByte(CP_UTF8, 0, test->utf16, test->utf16len,
nullptr, 0,
nullptr,
nullptr);
611 size_t wlen = strnlen(test->utf8, test->utf8len);
612 if (isNullTerminated)
617 char prefix[8192] = WINPR_C_ARRAY_INIT;
618 create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf16len, test, __func__, __LINE__);
619 (void)fprintf(stderr,
620 "%s WideCharToMultiByte(CP_UTF8, 0, %s, %" PRIuz
621 ", nullptr, 0, nullptr, nullptr) expected %" PRIuz
", got %d\n",
622 prefix, test->utf8, test->utf16len, wlen, rc2);
626 for (
size_t x = 0; x < max; x++)
628 const size_t ilen[] = { TESTCASE_BUFFER_SIZE, test->utf16len, test->utf16len + 1,
629 test->utf16len - 1 };
630 const size_t imax = test->utf16len > 0 ? ARRAYSIZE(ilen) : ARRAYSIZE(ilen) - 1;
632 for (
size_t y = 0; y < imax; y++)
634 WCHAR wbuffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
635 char buffer[TESTCASE_BUFFER_SIZE] = WINPR_C_ARRAY_INIT;
636 memcpy(wbuffer, test->utf16, test->utf16len *
sizeof(WCHAR));
638 WideCharToMultiByte(CP_UTF8, 0, wbuffer, ilen[x], buffer, len[x],
nullptr,
nullptr);
639 if (!compare_win_utf8(buffer, len[x], rc, ilen[x], test))
647static BOOL test_win_conversion(
const testcase_t* testcases,
size_t count)
649 WINPR_ASSERT(testcases || (count == 0));
650 for (
size_t x = 0; x < count; x++)
652 const testcase_t* test = &testcases[x];
654 printf(
"Running test case %" PRIuz
" [%s]\n", x, test->utf8);
655 if (!test_win_convert_to_utf16(test))
657 if (!test_win_convert_to_utf16_n(test))
659 if (!test_win_convert_to_utf8(test))
661 if (!test_win_convert_to_utf8_n(test))
668#if defined(WITH_WINPR_DEPRECATED)
671static BYTE c_cedilla_UTF8[] =
"\xC3\xA7\x00";
672static BYTE c_cedilla_UTF16[] =
"\xE7\x00\x00\x00";
673static int c_cedilla_cchWideChar = 2;
674static int c_cedilla_cbMultiByte = 3;
678static BYTE en_Hello_UTF8[] =
"Hello\0";
679static BYTE en_Hello_UTF16[] =
"\x48\x00\x65\x00\x6C\x00\x6C\x00\x6F\x00\x00\x00";
680static int en_Hello_cchWideChar = 6;
681static int en_Hello_cbMultiByte = 6;
683static BYTE en_HowAreYou_UTF8[] =
"How are you?\0";
684static BYTE en_HowAreYou_UTF16[] =
685 "\x48\x00\x6F\x00\x77\x00\x20\x00\x61\x00\x72\x00\x65\x00\x20\x00"
686 "\x79\x00\x6F\x00\x75\x00\x3F\x00\x00\x00";
687static int en_HowAreYou_cchWideChar = 13;
688static int en_HowAreYou_cbMultiByte = 13;
692static BYTE fr_Hello_UTF8[] =
"Allo\0";
693static BYTE fr_Hello_UTF16[] =
"\x41\x00\x6C\x00\x6C\x00\x6F\x00\x00\x00";
694static int fr_Hello_cchWideChar = 5;
695static int fr_Hello_cbMultiByte = 5;
697static BYTE fr_HowAreYou_UTF8[] =
698 "\x43\x6F\x6D\x6D\x65\x6E\x74\x20\xC3\xA7\x61\x20\x76\x61\x3F\x00";
699static BYTE fr_HowAreYou_UTF16[] =
700 "\x43\x00\x6F\x00\x6D\x00\x6D\x00\x65\x00\x6E\x00\x74\x00\x20\x00"
701 "\xE7\x00\x61\x00\x20\x00\x76\x00\x61\x00\x3F\x00\x00\x00";
702static int fr_HowAreYou_cchWideChar = 15;
703static int fr_HowAreYou_cbMultiByte = 16;
707static BYTE ru_Hello_UTF8[] =
"\xD0\x97\xD0\xB4\xD0\xBE\xD1\x80\xD0\xBE\xD0\xB2\xD0\xBE\x00";
708static BYTE ru_Hello_UTF16[] =
"\x17\x04\x34\x04\x3E\x04\x40\x04\x3E\x04\x32\x04\x3E\x04\x00\x00";
709static int ru_Hello_cchWideChar = 8;
710static int ru_Hello_cbMultiByte = 15;
712static BYTE ru_HowAreYou_UTF8[] =
713 "\xD0\x9A\xD0\xB0\xD0\xBA\x20\xD0\xB4\xD0\xB5\xD0\xBB\xD0\xB0\x3F\x00";
714static BYTE ru_HowAreYou_UTF16[] =
715 "\x1A\x04\x30\x04\x3A\x04\x20\x00\x34\x04\x35\x04\x3B\x04\x30\x04"
717static int ru_HowAreYou_cchWideChar = 10;
718static int ru_HowAreYou_cbMultiByte = 17;
722static BYTE ar_Hello_UTF8[] =
"\xD8\xA7\xD9\x84\xD8\xB3\xD9\x84\xD8\xA7\xD9\x85\x20\xD8\xB9\xD9"
723 "\x84\xD9\x8A\xD9\x83\xD9\x85\x00";
724static BYTE ar_Hello_UTF16[] =
"\x27\x06\x44\x06\x33\x06\x44\x06\x27\x06\x45\x06\x20\x00\x39\x06"
725 "\x44\x06\x4A\x06\x43\x06\x45\x06\x00\x00";
726static int ar_Hello_cchWideChar = 13;
727static int ar_Hello_cbMultiByte = 24;
729static BYTE ar_HowAreYou_UTF8[] =
"\xD9\x83\xD9\x8A\xD9\x81\x20\xD8\xAD\xD8\xA7\xD9\x84\xD9\x83\xD8"
731static BYTE ar_HowAreYou_UTF16[] =
732 "\x43\x06\x4A\x06\x41\x06\x20\x00\x2D\x06\x27\x06\x44\x06\x43\x06"
734static int ar_HowAreYou_cchWideChar = 10;
735static int ar_HowAreYou_cbMultiByte = 18;
739static BYTE ch_Hello_UTF8[] =
"\xE4\xBD\xA0\xE5\xA5\xBD\x00";
740static BYTE ch_Hello_UTF16[] =
"\x60\x4F\x7D\x59\x00\x00";
741static int ch_Hello_cchWideChar = 3;
742static int ch_Hello_cbMultiByte = 7;
744static BYTE ch_HowAreYou_UTF8[] =
"\xE4\xBD\xA0\xE5\xA5\xBD\xE5\x90\x97\x00";
745static BYTE ch_HowAreYou_UTF16[] =
"\x60\x4F\x7D\x59\x17\x54\x00\x00";
746static int ch_HowAreYou_cchWideChar = 4;
747static int ch_HowAreYou_cbMultiByte = 10;
751static BYTE ru_Administrator_lower[] =
"\xd0\x90\xd0\xb4\xd0\xbc\xd0\xb8\xd0\xbd\xd0\xb8\xd1\x81"
752 "\xd1\x82\xd1\x80\xd0\xb0\xd1\x82\xd0\xbe\xd1\x80\x00";
754static BYTE ru_Administrator_upper[] =
"\xd0\x90\xd0\x94\xd0\x9c\xd0\x98\xd0\x9d\xd0\x98\xd0\xa1"
755 "\xd0\xa2\xd0\xa0\xd0\x90\xd0\xa2\xd0\x9e\xd0\xa0\x00";
757static void string_hexdump(
const BYTE* data,
size_t length)
761 char* str = winpr_BinToHexString(data, length, TRUE);
765 while (offset < length)
767 const size_t diff = (length - offset) * 3;
768 WINPR_ASSERT(diff <= INT_MAX);
769 printf(
"%04" PRIxz
" %.*s\n", offset, (
int)diff, &str[offset]);
776static int convert_utf8_to_utf16(BYTE* lpMultiByteStr, BYTE* expected_lpWideCharStr,
777 int expected_cchWideChar)
781 size_t cbMultiByte = 0;
783 LPWSTR lpWideCharStr =
nullptr;
785 cbMultiByte = strlen((
char*)lpMultiByteStr);
786 cchWideChar = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)lpMultiByteStr, -1,
nullptr, 0);
788 printf(
"MultiByteToWideChar Input UTF8 String:\n");
789 string_hexdump(lpMultiByteStr, cbMultiByte + 1);
791 printf(
"MultiByteToWideChar required cchWideChar: %d\n", cchWideChar);
793 if (cchWideChar != expected_cchWideChar)
795 printf(
"MultiByteToWideChar unexpected cchWideChar: actual: %d expected: %d\n", cchWideChar,
796 expected_cchWideChar);
800 lpWideCharStr = (LPWSTR)calloc((
size_t)cchWideChar,
sizeof(WCHAR));
803 printf(
"MultiByteToWideChar: unable to allocate memory for test\n");
806 lpWideCharStr[cchWideChar - 1] =
808 length = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)lpMultiByteStr, cbMultiByte + 1, lpWideCharStr,
811 printf(
"MultiByteToWideChar converted length (WCHAR): %d\n", length);
815 DWORD error = GetLastError();
816 printf(
"MultiByteToWideChar error: 0x%08" PRIX32
"\n", error);
820 if (length != expected_cchWideChar)
822 printf(
"MultiByteToWideChar unexpected converted length (WCHAR): actual: %d expected: %d\n",
823 length, expected_cchWideChar);
827 if (_wcscmp(lpWideCharStr, (WCHAR*)expected_lpWideCharStr) != 0)
829 printf(
"MultiByteToWideChar unexpected string:\n");
831 printf(
"UTF8 String:\n");
832 string_hexdump(lpMultiByteStr, cbMultiByte + 1);
834 printf(
"UTF16 String (actual):\n");
835 string_hexdump((BYTE*)lpWideCharStr, length *
sizeof(WCHAR));
837 printf(
"UTF16 String (expected):\n");
838 string_hexdump(expected_lpWideCharStr, expected_cchWideChar *
sizeof(WCHAR));
843 printf(
"MultiByteToWideChar Output UTF16 String:\n");
844 string_hexdump((BYTE*)lpWideCharStr, length *
sizeof(WCHAR));
855#if defined(WITH_WINPR_DEPRECATED)
856static int convert_utf16_to_utf8(BYTE* lpWideCharStr, BYTE* expected_lpMultiByteStr,
857 int expected_cbMultiByte)
863 LPSTR lpMultiByteStr =
nullptr;
865 cchWideChar = _wcslen((WCHAR*)lpWideCharStr);
867 WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)lpWideCharStr, -1,
nullptr, 0,
nullptr,
nullptr);
869 printf(
"WideCharToMultiByte Input UTF16 String:\n");
870 string_hexdump(lpWideCharStr, (cchWideChar + 1) *
sizeof(WCHAR));
872 printf(
"WideCharToMultiByte required cbMultiByte: %d\n", cbMultiByte);
874 if (cbMultiByte != expected_cbMultiByte)
876 printf(
"WideCharToMultiByte unexpected cbMultiByte: actual: %d expected: %d\n", cbMultiByte,
877 expected_cbMultiByte);
881 lpMultiByteStr = (LPSTR)malloc(cbMultiByte);
884 printf(
"WideCharToMultiByte: unable to allocate memory for test\n");
887 lpMultiByteStr[cbMultiByte - 1] =
889 length = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)lpWideCharStr, cchWideChar + 1,
890 lpMultiByteStr, cbMultiByte,
nullptr,
nullptr);
892 printf(
"WideCharToMultiByte converted length (BYTE): %d\n", length);
896 DWORD error = GetLastError();
897 printf(
"WideCharToMultiByte error: 0x%08" PRIX32
"\n", error);
901 if (length != expected_cbMultiByte)
903 printf(
"WideCharToMultiByte unexpected converted length (BYTE): actual: %d expected: %d\n",
904 length, expected_cbMultiByte);
908 if (strcmp(lpMultiByteStr, (
char*)expected_lpMultiByteStr) != 0)
910 printf(
"WideCharToMultiByte unexpected string:\n");
912 printf(
"UTF16 String:\n");
913 string_hexdump(lpWideCharStr, (cchWideChar + 1) *
sizeof(WCHAR));
915 printf(
"UTF8 String (actual):\n");
916 string_hexdump((BYTE*)lpMultiByteStr, cbMultiByte);
918 printf(
"UTF8 String (expected):\n");
919 string_hexdump(expected_lpMultiByteStr, expected_cbMultiByte);
924 printf(
"WideCharToMultiByte Output UTF8 String:\n");
925 string_hexdump((BYTE*)lpMultiByteStr, cbMultiByte);
930 free(lpMultiByteStr);
936#if defined(WITH_WINPR_DEPRECATED)
937static BOOL test_unicode_uppercasing(BYTE* lower, BYTE* upper)
939 WCHAR* lowerW =
nullptr;
941 WCHAR* upperW =
nullptr;
944 lowerLength = ConvertToUnicode(CP_UTF8, 0, (LPSTR)lower, -1, &lowerW, 0);
945 upperLength = ConvertToUnicode(CP_UTF8, 0, (LPSTR)upper, -1, &upperW, 0);
947 CharUpperBuffW(lowerW, lowerLength);
949 if (_wcscmp(lowerW, upperW) != 0)
951 printf(
"Lowercase String:\n");
952 string_hexdump((BYTE*)lowerW, lowerLength * 2);
954 printf(
"Uppercase String:\n");
955 string_hexdump((BYTE*)upperW, upperLength * 2);
963 printf(
"success\n\n");
968#if defined(WITH_WINPR_DEPRECATED)
969static BOOL test_ConvertFromUnicode_wrapper(
void)
972 "\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00\x20\x00\x46\x00"
973 "\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x40\x00\x40\x00\x40\x00";
974 const BYTE src2[] =
"\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00"
975 "\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x00\x00";
977 const CHAR cmp0[] = {
'R',
'I',
'C',
'H',
' ',
'T',
'E',
'X',
'T',
978 ' ',
'F',
'O',
'R',
'M',
'A',
'T', 0 };
986 printf(
"Input UTF16 String:\n");
987 string_hexdump((
const BYTE*)src1, 19 *
sizeof(WCHAR));
989 i = ConvertFromUnicode(CP_UTF8, 0, (
const WCHAR*)src1, 16, &dst, 0,
nullptr,
nullptr);
992 (void)fprintf(stderr,
993 "ConvertFromUnicode failure A1: unexpectedly returned %d instead of 16\n", i);
998 (void)fprintf(stderr,
"ConvertFromUnicode failure A2: destination is nullptr\n");
1001 if ((i = strlen(dst)) != 16)
1003 (void)fprintf(stderr,
"ConvertFromUnicode failure A3: dst length is %d instead of 16\n", i);
1006 if (strcmp(dst, cmp0))
1008 (void)fprintf(stderr,
"ConvertFromUnicode failure A4: data mismatch\n");
1011 printf(
"Output UTF8 String:\n");
1012 string_hexdump((BYTE*)dst, i + 1);
1019 printf(
"Input UTF16 String:\n");
1020 string_hexdump((
const BYTE*)src2, (_wcslen((
const WCHAR*)src2) + 1) *
sizeof(WCHAR));
1022 i = ConvertFromUnicode(CP_UTF8, 0, (
const WCHAR*)src2, -1, &dst, 0,
nullptr,
nullptr);
1025 (void)fprintf(stderr,
1026 "ConvertFromUnicode failure B1: unexpectedly returned %d instead of 17\n", i);
1031 (void)fprintf(stderr,
"ConvertFromUnicode failure B2: destination is nullptr\n");
1034 if ((i = strlen(dst)) != 16)
1036 (void)fprintf(stderr,
"ConvertFromUnicode failure B3: dst length is %d instead of 16\n", i);
1039 if (strcmp(dst, cmp0))
1041 (void)fprintf(stderr,
"ConvertFromUnicode failure B: data mismatch\n");
1044 printf(
"Output UTF8 String:\n");
1045 string_hexdump((BYTE*)dst, i + 1);
1050 printf(
"success\n\n");
1059static BOOL test_ConvertToUnicode_wrapper(
void)
1062 const CHAR src1[] = {
'R',
'I',
'C',
'H',
' ',
'T',
'E',
'X',
'T',
' ',
1063 'F',
'O',
'R',
'M',
'A',
'T',
'@',
'@',
'@' };
1064 const CHAR src2[] = {
'R',
'I',
'C',
'H',
' ',
'T',
'E',
'X',
'T',
1065 ' ',
'F',
'O',
'R',
'M',
'A',
'T', 0 };
1066 const BYTE cmp0[] =
"\x52\x00\x49\x00\x43\x00\x48\x00\x20\x00\x54\x00\x45\x00\x58\x00\x54\x00"
1067 "\x20\x00\x46\x00\x4f\x00\x52\x00\x4d\x00\x41\x00\x54\x00\x00\x00";
1068 WCHAR* dst =
nullptr;
1074 char name[] =
"someteststring";
1075 const BYTE cmp[] = {
's', 0,
'o', 0,
'm', 0,
'e', 0,
't', 0,
'e', 0,
's', 0,
't', 0,
1076 's', 0,
't', 0,
'r', 0,
'i', 0,
'n', 0,
'g', 0, 0, 0 };
1077 WCHAR xname[128] = WINPR_C_ARRAY_INIT;
1078 LPWSTR aname =
nullptr;
1079 LPWSTR wname = &xname[0];
1080 const size_t len = strnlen(name, ARRAYSIZE(name) - 1);
1081 ii = ConvertToUnicode(CP_UTF8, 0, name, len, &wname, ARRAYSIZE(xname));
1082 if (ii != (SSIZE_T)len)
1085 if (memcmp(wname, cmp,
sizeof(cmp)) != 0)
1088 ii = ConvertToUnicode(CP_UTF8, 0, name, len, &aname, 0);
1089 if (ii != (SSIZE_T)len)
1091 ii = memcmp(aname, cmp,
sizeof(cmp));
1101 printf(
"Input UTF8 String:\n");
1102 string_hexdump((
const BYTE*)src1, 19);
1104 ii = ConvertToUnicode(CP_UTF8, 0, src1, 16, &dst, 0);
1107 (void)fprintf(stderr,
1108 "ConvertToUnicode failure A1: unexpectedly returned %d instead of 16\n", ii);
1114 (void)fprintf(stderr,
"ConvertToUnicode failure A2: destination is nullptr\n");
1117 if ((i = _wcslen(dst)) != 16)
1119 (void)fprintf(stderr,
1120 "ConvertToUnicode failure A3: dst length is %" PRIuz
" instead of 16\n", i);
1123 if (_wcscmp(dst, (
const WCHAR*)cmp0))
1125 (void)fprintf(stderr,
"ConvertToUnicode failure A4: data mismatch\n");
1128 printf(
"Output UTF16 String:\n");
1129 string_hexdump((
const BYTE*)dst, (i + 1) *
sizeof(WCHAR));
1136 printf(
"Input UTF8 String:\n");
1137 string_hexdump((
const BYTE*)src2, strlen(src2) + 1);
1139 i = ConvertToUnicode(CP_UTF8, 0, src2, -1, &dst, 0);
1143 stderr,
"ConvertToUnicode failure B1: unexpectedly returned %" PRIuz
" instead of 17\n",
1149 (void)fprintf(stderr,
"ConvertToUnicode failure B2: destination is nullptr\n");
1152 if ((i = _wcslen(dst)) != 16)
1154 (void)fprintf(stderr,
1155 "ConvertToUnicode failure B3: dst length is %" PRIuz
" instead of 16\n", i);
1158 if (_wcscmp(dst, (
const WCHAR*)cmp0))
1160 (void)fprintf(stderr,
"ConvertToUnicode failure B: data mismatch\n");
1163 printf(
"Output UTF16 String:\n");
1164 string_hexdump((BYTE*)dst, (i + 1) * 2);
1169 printf(
"success\n\n");
1179#if defined(BUILD_TESTING_INTERNAL)
1189static BOOL testEscapeCase(
const test_case_t* test)
1195 char* cmp =
nullptr;
1196 WINPR_ASSERT(test->utf8len == strlen(test->utf8));
1197 char* str = winpr_utf8ToUtfEscapedString(test->utf8, test->utf8len, &dlen);
1198 if (dlen != test->esclen)
1200 (void)fprintf(stderr,
"[%s] length 1 mismatch %" PRIuz
" vs %" PRIuz, __func__, dlen,
1204 if (strncmp(test->esc, str, test->esclen + 1) != 0)
1206 (void)fprintf(stderr,
"[%s] strcmp 1 mismatch %s vs %s", __func__, str, test->esc);
1210 cmp = strndup(str, dlen);
1213 (void)fprintf(stderr,
"[%s] strndup(%s, %" PRIuz
") mismatch", __func__, str, dlen);
1216 WINPR_ASSERT(test->esclen == strlen(test->esc));
1217 const SSIZE_T res = winpr_utfEscapedStringToUtf8(cmp, dlen);
1220 (void)fprintf(stderr,
"[%s] winpr_utfEscapedStringToUtf8(%s, %" PRIuz
") failed", __func__,
1225 if ((
size_t)res != test->utf8len)
1227 (void)fprintf(stderr,
"[%s] length 2 mismatch %" PRIdz
" vs %" PRIuz, __func__, res,
1231 if (strncmp(test->utf8, cmp, test->utf8len + 1) != 0)
1233 (void)fprintf(stderr,
"[%s] strcmp 2 mismatch %s vs %s", __func__, cmp, test->utf8);
1245static BOOL testEscape(
void)
1247 const test_case_t tests[] = {
1248 {
"abc", 3,
"abc", 3 },
1249 {
"Υ", 2,
"\\u055e", 6 },
1250 {
"β·", 3,
"\\u27f7", 6 },
1251 {
"π", 4,
"\\ud808\\udc00", 12 },
1252 {
"Υaβ·bπc", 12,
"\\u055ea\\u27f7b\\ud808\\udc00c", 27 },
1253 {
"Υβ·ππβ·β·ΥΥ", 23,
"\\u055e\\u27f7\\ud808\\udc00\\ud808\\udc00\\u27f7\\u27f7\\u055e\\u055e",
1257 for (
size_t x = 0; x < ARRAYSIZE(tests); x++)
1259 const test_case_t* cur = &tests[x];
1260 if (!testEscapeCase(cur))
1262 (void)fprintf(stderr,
"Test case %" PRIuz
" %s escaped string failed\n", x, cur->utf8);
1270static BOOL testUnescapeLiteral(
void)
1277 } tests[] = { {
"C:\\users\\test",
"C:\\users\\test" },
1278 {
"see \\utils here",
"see \\utils here" },
1279 {
"end \\u12",
"end \\u12" },
1280 {
"\\uzzzz\\u0041",
"\\uzzzzA" },
1281 {
"\\u005cu0041",
"\\u0041" } };
1283 for (
size_t x = 0; x < ARRAYSIZE(tests); x++)
1285 char* str = _strdup(tests[x].in);
1289 const SSIZE_T res = winpr_utfEscapedStringToUtf8(str, strlen(str));
1291 (res >= 0) && ((
size_t)res == strlen(tests[x].out)) && (strcmp(str, tests[x].out) == 0);
1293 (void)fprintf(stderr,
"unescape '%s': got '%s', expected '%s'\n", tests[x].in, str,
1303int TestUnicodeConversion(
int argc,
char* argv[])
1308 if (!test_conversion(unit_testcases, ARRAYSIZE(unit_testcases)))
1311#if defined(WITH_WINPR_DEPRECATED)
1312 if (!test_win_conversion(unit_testcases, ARRAYSIZE(unit_testcases)))
1317 printf(
"Letters\n");
1319 if (convert_utf8_to_utf16(c_cedilla_UTF8, c_cedilla_UTF16, c_cedilla_cchWideChar) < 1)
1322 if (convert_utf16_to_utf8(c_cedilla_UTF16, c_cedilla_UTF8, c_cedilla_cbMultiByte) < 1)
1327 printf(
"English\n");
1329 if (convert_utf8_to_utf16(en_Hello_UTF8, en_Hello_UTF16, en_Hello_cchWideChar) < 1)
1331 if (convert_utf8_to_utf16(en_HowAreYou_UTF8, en_HowAreYou_UTF16, en_HowAreYou_cchWideChar) < 1)
1334 if (convert_utf16_to_utf8(en_Hello_UTF16, en_Hello_UTF8, en_Hello_cbMultiByte) < 1)
1336 if (convert_utf16_to_utf8(en_HowAreYou_UTF16, en_HowAreYou_UTF8, en_HowAreYou_cbMultiByte) < 1)
1343 if (convert_utf8_to_utf16(fr_Hello_UTF8, fr_Hello_UTF16, fr_Hello_cchWideChar) < 1)
1345 if (convert_utf8_to_utf16(fr_HowAreYou_UTF8, fr_HowAreYou_UTF16, fr_HowAreYou_cchWideChar) < 1)
1348 if (convert_utf16_to_utf8(fr_Hello_UTF16, fr_Hello_UTF8, fr_Hello_cbMultiByte) < 1)
1350 if (convert_utf16_to_utf8(fr_HowAreYou_UTF16, fr_HowAreYou_UTF8, fr_HowAreYou_cbMultiByte) < 1)
1355 printf(
"Russian\n");
1357 if (convert_utf8_to_utf16(ru_Hello_UTF8, ru_Hello_UTF16, ru_Hello_cchWideChar) < 1)
1359 if (convert_utf8_to_utf16(ru_HowAreYou_UTF8, ru_HowAreYou_UTF16, ru_HowAreYou_cchWideChar) < 1)
1362 if (convert_utf16_to_utf8(ru_Hello_UTF16, ru_Hello_UTF8, ru_Hello_cbMultiByte) < 1)
1364 if (convert_utf16_to_utf8(ru_HowAreYou_UTF16, ru_HowAreYou_UTF8, ru_HowAreYou_cbMultiByte) < 1)
1371 if (convert_utf8_to_utf16(ar_Hello_UTF8, ar_Hello_UTF16, ar_Hello_cchWideChar) < 1)
1373 if (convert_utf8_to_utf16(ar_HowAreYou_UTF8, ar_HowAreYou_UTF16, ar_HowAreYou_cchWideChar) < 1)
1376 if (convert_utf16_to_utf8(ar_Hello_UTF16, ar_Hello_UTF8, ar_Hello_cbMultiByte) < 1)
1378 if (convert_utf16_to_utf8(ar_HowAreYou_UTF16, ar_HowAreYou_UTF8, ar_HowAreYou_cbMultiByte) < 1)
1383 printf(
"Chinese\n");
1385 if (convert_utf8_to_utf16(ch_Hello_UTF8, ch_Hello_UTF16, ch_Hello_cchWideChar) < 1)
1387 if (convert_utf8_to_utf16(ch_HowAreYou_UTF8, ch_HowAreYou_UTF16, ch_HowAreYou_cchWideChar) < 1)
1390 if (convert_utf16_to_utf8(ch_Hello_UTF16, ch_Hello_UTF8, ch_Hello_cbMultiByte) < 1)
1392 if (convert_utf16_to_utf8(ch_HowAreYou_UTF16, ch_HowAreYou_UTF8, ch_HowAreYou_cbMultiByte) < 1)
1398#if defined(WITH_WINPR_DEPRECATED)
1399 printf(
"Uppercasing\n");
1401 if (!test_unicode_uppercasing(ru_Administrator_lower, ru_Administrator_upper))
1406#if defined(WITH_WINPR_DEPRECATED)
1407 printf(
"ConvertFromUnicode\n");
1409 if (!test_ConvertFromUnicode_wrapper())
1414 printf(
"ConvertToUnicode\n");
1416 if (!test_ConvertToUnicode_wrapper())
1447#if defined(BUILD_TESTING_INTERNAL)
1450 if (!testUnescapeLiteral())