From 5f0b099e1444d462be5aa8df49f87c9b324e1b85 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 3 Sep 2024 01:32:00 -0400 Subject: [PATCH] Better behavior for invalid character names --- builtins/text.c | 3 ++- test/text.tm | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/builtins/text.c b/builtins/text.c index a9a246e..99d1757 100644 --- a/builtins/text.c +++ b/builtins/text.c @@ -1610,7 +1610,8 @@ public Text_t Text$from_codepoint_names(array_t codepoint_names) Text_t *name = ((Text_t*)(codepoint_names.data + i*codepoint_names.stride)); const char *name_str = Text$as_c_string(*name); uint32_t codepoint = unicode_name_character(name_str); - Array$insert(&codepoints, &codepoint, I_small(0), sizeof(uint32_t)); + if (codepoint != UNINAME_INVALID) + Array$insert(&codepoints, &codepoint, I_small(0), sizeof(uint32_t)); } return Text$from_codepoints(codepoints); } diff --git a/test/text.tm b/test/text.tm index f0f289f..d82a38c 100644 --- a/test/text.tm +++ b/test/text.tm @@ -217,3 +217,6 @@ func main(): >> "🐧":codepoint_names() = ["PENGUIN"] + >> Text.from_codepoint_names(["not a valid name here buddy"]) + = "" +