Skip to content

Commit 908b11d

Browse files
committed
tests: internal: unicode: Use binary representation to prevent garbage characters
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 2d982a0 commit 908b11d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/internal/unicode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ void test_generic_conversions_sjis()
6464
TEST_MSG("SJIS to UTF-8 conversion failed.");
6565
return;
6666
}
67-
printf("UTF-8: %s", utf8_output);
68-
if (!TEST_CHECK(strncmp((char *)utf8_output, "こんにちは", utf8_len) == 0)) {
67+
if (!TEST_CHECK(strncmp((char *)utf8_output, "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf", utf8_len) == 0)) {
6968
TEST_MSG("conversion check failed");
7069
return;
7170
}
@@ -88,7 +87,7 @@ void test_generic_conversions_sjis()
8887
void test_generic_conversions_gbk()
8988
{
9089
const char *gbk_input = "\xc4\xe3\xba\xc3"; // "你好" (Nǐ hǎo) in GBK
91-
const char *utf8_equivalent = "你好";
90+
const char *utf8_equivalent = "\xE4\xBD\xA0\xE5\xA5\xBD";
9291
unsigned char *utf8_output = NULL;
9392
unsigned char *gbk_output = NULL;
9493

@@ -119,7 +118,7 @@ void test_generic_conversions_gbk()
119118
void test_generic_conversions_big5()
120119
{
121120
const char *big5_input = "\xa4\xa4\xa4\xe5"; // "中文" (Zhōngwén) in Big5
122-
const char *utf8_equivalent = "中文";
121+
const char *utf8_equivalent = "\xE4\xB8\xAD\xE6\x96\x87";
123122
unsigned char *utf8_output = NULL;
124123
unsigned char *big5_output = NULL;
125124

0 commit comments

Comments
 (0)