diff options
| author | 2024-11-20 18:10:02 +0100 | |
|---|---|---|
| committer | 2024-11-20 18:10:02 +0100 | |
| commit | c507e30607812c4c2ab2dd27835eb5f2ea6a9742 (patch) | |
| tree | 97aab176eed32cff58a30cfbd60eb7a96655583a /xs_unicode.h | |
| parent | mastoapi: fixed crash in posts without 'published' field. (diff) | |
| download | penes-snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.tar.gz penes-snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.tar.xz penes-snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.zip | |
New function xs_unicode_right_to_left().
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) |