Skip to content

Commit 492addb

Browse files
authored
Enc: add unicode case mappings (#5956)
1 parent 00fba1d commit 492addb

File tree

5 files changed

+818
-0
lines changed

5 files changed

+818
-0
lines changed

librz/include/rz_util/rz_unicode.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ typedef struct rz_unicode_range_entry_t RzUnicodeRangeTable[];
4343
*/
4444
typedef ut32 RzCodePoint;
4545

46+
typedef struct rz_unicode_case_mapping_t {
47+
RzCodePoint key;
48+
RzCodePoint val[3];
49+
} RzUnicodeCaseMapping;
50+
51+
typedef RzUnicodeCaseMapping RzUnicodeCaseMap[];
52+
4653
RZ_API bool rz_unicode_code_point_is_printable(const RzCodePoint c);
4754
RZ_API bool rz_unicode_code_point_is_defined(const RzCodePoint c);
4855
RZ_API bool rz_unicode_code_point_is_legal_decode(const RzCodePoint c);
@@ -53,5 +60,9 @@ RZ_API bool rz_unicode_code_point_is_format(const RzCodePoint c);
5360
RZ_API RzStrEnc rz_unicode_bom_encoding(const ut8 *ptr, size_t ptrlen);
5461
RZ_API void rz_unicode_code_point_escape(RzCodePoint code_point, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt);
5562
RZ_API void rz_unicode_byte_escape(char ch, RZ_NONNULL RZ_OUT char **dst, RZ_NONNULL const RzStrEscOptions *opt);
63+
RZ_API RzUnicodeCaseMapping rz_unicode_case_mapping_default(RzCodePoint key);
64+
RZ_API bool rz_unicode_case_mapping_is_empty(RZ_NULLABLE const RzUnicodeCaseMapping *um);
65+
RZ_API RzUnicodeCaseMapping rz_unicode_code_point_find_lower(RzCodePoint c);
66+
RZ_API RzUnicodeCaseMapping rz_unicode_code_point_find_upper(RzCodePoint c);
5667

5768
#endif // RZ_UNICODE_H

librz/include/rz_util/rz_utf8.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ RZ_API int rz_mutf8_decode(const ut8 *ptr, int ptrlen, RzCodePoint *ch);
1818
RZ_API int rz_utf8_encode_str(const RzCodePoint *str, ut8 *dst, const int dst_length);
1919
RZ_API int rz_utf8_size(const ut8 *ptr);
2020
RZ_API size_t rz_utf8_strlen(const ut8 *str);
21+
RZ_API size_t rz_utf8_strnlen(RZ_NULLABLE const ut8 *str, size_t maxlen);
2122
RZ_API const char *rz_utf_block_name(int idx);
2223
RZ_API int rz_utf_block_idx(RzCodePoint ch);
2324
RZ_API int *rz_utf_block_list(const ut8 *str, int len, int **freq_list);
25+
RZ_API size_t rz_utf8_byte_length(RzCodePoint c);
2426
#if __WINDOWS__
2527
#define rz_utf16_to_utf8(wc) rz_utf16_to_utf8_l((wchar_t *)wc, -1)
2628
#define rz_utf8_to_utf16(cstring) rz_utf8_to_utf16_l((char *)cstring, -1)

0 commit comments

Comments
 (0)