LibUnicode: Add a helper to determine if a code point is printable

This commit is contained in:
Timothy Flynn 2024-10-21 16:29:16 -04:00 committed by Jelle Raaijmakers
commit 1bbe8309d4
Notes: github-actions[bot] 2024-10-22 10:50:00 +00:00
2 changed files with 6 additions and 0 deletions

View file

@ -108,6 +108,11 @@ bool code_point_has_general_category(u32 code_point, GeneralCategory general_cat
return u_charType(icu_code_point) == icu_general_category; return u_charType(icu_code_point) == icu_general_category;
} }
bool code_point_is_printable(u32 code_point)
{
return static_cast<bool>(u_isprint(static_cast<UChar32>(code_point)));
}
bool code_point_has_control_general_category(u32 code_point) bool code_point_has_control_general_category(u32 code_point)
{ {
return code_point_has_general_category(code_point, U_CONTROL_CHAR); return code_point_has_general_category(code_point, U_CONTROL_CHAR);

View file

@ -17,6 +17,7 @@ namespace Unicode {
Optional<GeneralCategory> general_category_from_string(StringView); Optional<GeneralCategory> general_category_from_string(StringView);
bool code_point_has_general_category(u32 code_point, GeneralCategory general_category); bool code_point_has_general_category(u32 code_point, GeneralCategory general_category);
bool code_point_is_printable(u32 code_point);
bool code_point_has_control_general_category(u32 code_point); bool code_point_has_control_general_category(u32 code_point);
bool code_point_has_letter_general_category(u32 code_point); bool code_point_has_letter_general_category(u32 code_point);
bool code_point_has_number_general_category(u32 code_point); bool code_point_has_number_general_category(u32 code_point);