Better behavior for invalid character names

This commit is contained in:
Bruce Hill 2024-09-03 01:32:00 -04:00
parent b517f3b287
commit 5f0b099e14
2 changed files with 5 additions and 1 deletions

View File

@ -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);
}

View File

@ -217,3 +217,6 @@ func main():
>> "🐧":codepoint_names()
= ["PENGUIN"]
>> Text.from_codepoint_names(["not a valid name here buddy"])
= ""