aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtins/text.c2
-rw-r--r--test/text.tm9
2 files changed, 11 insertions, 0 deletions
diff --git a/builtins/text.c b/builtins/text.c
index c4514892..66622f5f 100644
--- a/builtins/text.c
+++ b/builtins/text.c
@@ -1573,12 +1573,14 @@ public array_t Text$codepoint_names(Text_t text)
for (int64_t c = 0; c < synthetic_graphemes[-grapheme-1].num_codepoints; c++) {
char *name = GC_MALLOC_ATOMIC(UNINAME_MAX);
name = unicode_character_name(synthetic_graphemes[-grapheme-1].codepoints[c], name);
+ if (!name) name = "???";
Text_t name_text = (Text_t){.tag=TEXT_ASCII, .length=strlen(name), .ascii=name};
Array$insert(&names, &name_text, I_small(0), sizeof(Text_t));
}
} else {
char *name = GC_MALLOC_ATOMIC(UNINAME_MAX);
name = unicode_character_name(grapheme, name);
+ if (!name) name = "???";
Text_t name_text = (Text_t){.tag=TEXT_ASCII, .length=strlen(name), .ascii=name};
Array$insert(&names, &name_text, I_small(0), sizeof(Text_t));
}
diff --git a/test/text.tm b/test/text.tm
index b1c4b758..4dd431ca 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -204,3 +204,12 @@ func main():
= "bcd"
>> "abcdef":slice(from=5, to=1)
= ""
+
+ >> house := "家"
+ = "家"
+ >> house.length
+ = 1
+ >> house:codepoint_names()
+ = ["???"]
+ >> house:utf32_codepoints()
+ = [23478_i32]