diff options
| author | shtrophic <shtrophic@noreply.codeberg.org> | 2024-11-20 18:13:44 +0000 |
|---|---|---|
| committer | shtrophic <shtrophic@noreply.codeberg.org> | 2024-11-20 18:13:44 +0000 |
| commit | 4867587032de0237aeff850ddedb1733c1f16073 (patch) | |
| tree | a6da07b5cf657a3c93d5276fdfd041a9e0fbe403 /xs_unicode.h | |
| parent | 80ff16b21c7081165d346ff94b450f432a82ee47 (diff) | |
| parent | c507e30607812c4c2ab2dd27835eb5f2ea6a9742 (diff) | |
Merge branch 'master' into master
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 @@ int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac); int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint); int xs_unicode_is_alpha(unsigned int cpoint); + int xs_unicode_is_right_to_left(unsigned int cpoint); #ifdef _XS_H 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) } +int xs_unicode_is_right_to_left(unsigned int cpoint) +/* checks if a codepoint is a right-to-left letter */ +{ + int b = 0; + int t = xs_countof(xs_unicode_right_to_left_table) / 2 - 1; + + while (t >= b) { + int n = (b + t) / 2; + unsigned int *p = &xs_unicode_right_to_left_table[n * 2]; + + if (cpoint < p[0]) + t = n - 1; + else + if (cpoint > p[1]) + b = n + 1; + else + return 1; + } + + return 0; +} + + #ifdef _XS_H xs_str *xs_utf8_to_upper(const char *str) |