diff options
| author | 2024-11-20 18:10:02 +0100 | |
|---|---|---|
| committer | 2024-11-20 18:10:02 +0100 | |
| commit | c507e30607812c4c2ab2dd27835eb5f2ea6a9742 (patch) | |
| tree | 97aab176eed32cff58a30cfbd60eb7a96655583a | |
| parent | mastoapi: fixed crash in posts without 'published' field. (diff) | |
| download | snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.tar.gz snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.tar.xz snac2-c507e30607812c4c2ab2dd27835eb5f2ea6a9742.zip | |
New function xs_unicode_right_to_left().
| -rw-r--r-- | xs_unicode.h | 24 | ||||
| -rw-r--r-- | xs_unicode_tbl.h | 15 | ||||
| -rw-r--r-- | xs_version.h | 2 |
3 files changed, 40 insertions, 1 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) |
diff --git a/xs_unicode_tbl.h b/xs_unicode_tbl.h index ecd537b..ee8ce97 100644 --- a/xs_unicode_tbl.h +++ b/xs_unicode_tbl.h | |||
| @@ -726,5 +726,20 @@ static unsigned int xs_unicode_alpha_table[] = { | |||
| 726 | 0x1E7E0, 0x1E8C4, 0x1E900, 0x1E943, 0x1EE00, 0x1EEBB, 0x20000, 0x323AF, | 726 | 0x1E7E0, 0x1E8C4, 0x1E900, 0x1E943, 0x1EE00, 0x1EEBB, 0x20000, 0x323AF, |
| 727 | }; | 727 | }; |
| 728 | 728 | ||
| 729 | static unsigned int xs_unicode_right_to_left_table[] = { | ||
| 730 | 0x05BE, 0x05BE, 0x05C0, 0x05C0, 0x05C3, 0x05C3, 0x05C6, 0x05C6, | ||
| 731 | 0x05D0, 0x05F4, 0x0608, 0x0608, 0x060B, 0x060B, 0x060D, 0x060D, | ||
| 732 | 0x061B, 0x064A, 0x066D, 0x066F, 0x0671, 0x06D5, 0x06E5, 0x06E6, | ||
| 733 | 0x06EE, 0x06EF, 0x06FA, 0x0710, 0x0712, 0x072F, 0x074D, 0x07A5, | ||
| 734 | 0x07B1, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x07FA, 0x07FE, 0x0815, | ||
| 735 | 0x081A, 0x081A, 0x0824, 0x0824, 0x0828, 0x0828, 0x0830, 0x0858, | ||
| 736 | 0x085E, 0x088E, 0x08A0, 0x08C9, 0x200F, 0x200F, 0xFB1D, 0xFB1D, | ||
| 737 | 0xFB1F, 0xFB28, 0xFB2A, 0xFD3D, 0xFD50, 0xFDC7, 0xFDF0, 0xFDFC, | ||
| 738 | 0xFE70, 0xFEFC, 0x10800, 0x1091B, 0x10920, 0x10A00, 0x10A10, 0x10A35, | ||
| 739 | 0x10A40, 0x10AE4, 0x10AEB, 0x10B35, 0x10B40, 0x10D23, 0x10E80, 0x10EA9, | ||
| 740 | 0x10EAD, 0x10EB1, 0x10F00, 0x10F45, 0x10F51, 0x10F81, 0x10F86, 0x10FF6, | ||
| 741 | 0x1E800, 0x1E8CF, 0x1E900, 0x1E943, 0x1E94B, 0x1EEBB, | ||
| 742 | }; | ||
| 743 | |||
| 729 | #endif /* _XS_UNICODE_TBL_H */ | 744 | #endif /* _XS_UNICODE_TBL_H */ |
| 730 | 745 | ||
diff --git a/xs_version.h b/xs_version.h index 84f7c5b..7c4246b 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* 35997d2dbc505320a62d3130daa95f638be8bb26 2024-11-05T16:47:36+01:00 */ | /* ab0749f821f1c98d16cbec53201bdf2ba2a24a43 2024-11-20T17:02:42+01:00 */ | ||