diff options
| author | 2024-12-05 22:53:40 +0100 | |
|---|---|---|
| committer | 2024-12-05 22:53:40 +0100 | |
| commit | bd74ffda5b25cc07e8d559815e027c8dab3b9d73 (patch) | |
| tree | 00725a5d5f53ed421b923de6fc1892c58815cc16 /xs_unicode.h | |
| parent | Makefile: enable static compilation with musl (diff) | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-bd74ffda5b25cc07e8d559815e027c8dab3b9d73.tar.gz snac2-bd74ffda5b25cc07e8d559815e027c8dab3b9d73.tar.xz snac2-bd74ffda5b25cc07e8d559815e027c8dab3b9d73.zip | |
Merge branch 'master' into build-with-musl
Diffstat (limited to 'xs_unicode.h')
| -rw-r--r-- | xs_unicode.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/xs_unicode.h b/xs_unicode.h index 9663190..cfcd8ff 100644 --- a/xs_unicode.h +++ b/xs_unicode.h | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac); | 21 | int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac); |
| 22 | int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint); | 22 | int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint); |
| 23 | int xs_unicode_is_alpha(unsigned int cpoint); | 23 | int xs_unicode_is_alpha(unsigned int cpoint); |
| 24 | int xs_unicode_is_right_to_left(unsigned int cpoint); | ||
| 24 | 25 | ||
| 25 | #ifdef _XS_H | 26 | #ifdef _XS_H |
| 26 | xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); | 27 | xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); |
| @@ -350,6 +351,29 @@ int xs_unicode_is_alpha(unsigned int cpoint) | |||
| 350 | } | 351 | } |
| 351 | 352 | ||
| 352 | 353 | ||
| 354 | int xs_unicode_is_right_to_left(unsigned int cpoint) | ||
| 355 | /* checks if a codepoint is a right-to-left letter */ | ||
| 356 | { | ||
| 357 | int b = 0; | ||
| 358 | int t = xs_countof(xs_unicode_right_to_left_table) / 2 - 1; | ||
| 359 | |||
| 360 | while (t >= b) { | ||
| 361 | int n = (b + t) / 2; | ||
| 362 | unsigned int *p = &xs_unicode_right_to_left_table[n * 2]; | ||
| 363 | |||
| 364 | if (cpoint < p[0]) | ||
| 365 | t = n - 1; | ||
| 366 | else | ||
| 367 | if (cpoint > p[1]) | ||
| 368 | b = n + 1; | ||
| 369 | else | ||
| 370 | return 1; | ||
| 371 | } | ||
| 372 | |||
| 373 | return 0; | ||
| 374 | } | ||
| 375 | |||
| 376 | |||
| 353 | #ifdef _XS_H | 377 | #ifdef _XS_H |
| 354 | 378 | ||
| 355 | xs_str *xs_utf8_to_upper(const char *str) | 379 | xs_str *xs_utf8_to_upper(const char *str) |