diff options
Diffstat (limited to 'include/unicode/string.h')
-rw-r--r-- | include/unicode/string.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/unicode/string.h b/include/unicode/string.h index 06edb6c..17ce561 100644 --- a/include/unicode/string.h +++ b/include/unicode/string.h @@ -18,6 +18,16 @@ enum [[clang::flag_enum]] caseflags { CF_ẞ = 1 << 3, /* Use ‘ẞ’ as the uppercase of ‘ß’; alias for CF_SS */ }; +enum normtype { + /* If bit 0 is set, then composition is performed after decomposition. If + bit-1 is set then compatibility (de)composition is used as opposed to + canonical (de)composition. */ + NT_NFD = 0b00, + NT_NFC = 0b01, + NT_NFKD = 0b10, + NT_NFKC = 0b11, +}; + /* clang-format on */ [[nodiscard]] size_t u8gcnt(struct u8view); @@ -34,8 +44,8 @@ size_t u8wnext_human(struct u8view *, struct u8view *); alloc_fn, void *); [[nodiscard]] char8_t *u8upper(size_t *, struct u8view, enum caseflags, alloc_fn, void *); -[[nodiscard]] char8_t *u8norm_nfd(size_t *, struct u8view, alloc_fn, void *); -[[nodiscard]] char8_t *u8norm_nfkd(size_t *, struct u8view, alloc_fn, void *); +[[nodiscard]] char8_t *u8norm(size_t *, struct u8view, alloc_fn, void *, + enum normtype); /* Encoding-generic macros */ #define ucsgcnt(sv) _Generic((sv), struct u8view: u8gcnt)((sv)) @@ -57,10 +67,8 @@ size_t u8wnext_human(struct u8view *, struct u8view *); #define ucsupper(dstn, sv, flags, alloc, ctx) \ _Generic((sv), struct u8view: u8upper)((dstn), (sv), (flags), (alloc), \ (ctx)) -#define ucsnorm_nfd(dstn, sv, alloc, ctx) \ - _Generic((sv), struct u8view: u8norm_nfd)((dstn), (sv), (alloc), (ctx)) -#define ucsnorm_nfkd(dstn, sv, alloc, ctx) \ - _Generic((sv), struct u8view: u8norm_nfkd)((dstn), (sv), (alloc), (ctx)) +#define ucsnorm(dstn, sv, alloc, ctx, nt) \ + _Generic((sv), struct u8view: u8norm)((dstn), (sv), (alloc), (ctx), (nt)) constexpr double U8CASEFOLD_SCALE = 3; constexpr double U8LOWER_SCALE = 1.5; |