From 7bef9b4a0a4e848e47601a7fb062b265075f241e Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Fri, 21 Mar 2025 05:06:20 +0100 Subject: [PATCH] lib: unichar - Implement uni_ucs4_to_titlecase() using the new Unicode character database --- src/lib/unichar.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/lib/unichar.c b/src/lib/unichar.c index 62402a48c8..2a59169413 100644 --- a/src/lib/unichar.c +++ b/src/lib/unichar.c @@ -3,6 +3,7 @@ #include "lib.h" #include "array.h" #include "bsearch-insert-pos.h" +#include "unicode-data.h" #include "unichar.h" #include "unicodemap.c" @@ -245,23 +246,12 @@ static bool uint32_find(const uint32_t *data, unsigned int count, unichar_t uni_ucs4_to_titlecase(unichar_t chr) { - unsigned int idx; + const struct unicode_code_point_data *cp_data = + unicode_code_point_get_data(chr); - if (chr <= 0xff) - return titlecase8_map[chr]; - else if (chr <= 0xffff) { - if (!uint16_find(titlecase16_keys, N_ELEMENTS(titlecase16_keys), - chr, &idx)) - return chr; - else - return titlecase16_values[idx]; - } else { - if (!uint32_find(titlecase32_keys, N_ELEMENTS(titlecase32_keys), - chr, &idx)) - return chr; - else - return titlecase32_values[idx]; - } + if (cp_data->simple_titlecase_mapping != 0x0000) + return cp_data->simple_titlecase_mapping; + return chr; } static bool uni_ucs4_decompose_uni(unichar_t *chr) -- 2.47.3