diff options
| author | 2025-12-18 07:58:24 +0100 | |
|---|---|---|
| committer | 2025-12-18 07:58:24 +0100 | |
| commit | 85ed0eb0d535700a5df837c37f51848811e461a0 (patch) | |
| tree | 818c80cc48c445b2950796230946c63eca3a3242 /xs_unicode.h | |
| parent | Bumped version. (diff) | |
| download | snac2-85ed0eb0d535700a5df837c37f51848811e461a0.tar.gz snac2-85ed0eb0d535700a5df837c37f51848811e461a0.tar.xz snac2-85ed0eb0d535700a5df837c37f51848811e461a0.zip | |
Added emoji reactions (contributed by violette).
Diffstat (limited to 'xs_unicode.h')
| -rw-r--r-- | xs_unicode.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/xs_unicode.h b/xs_unicode.h index 67b3827..0b4de1c 100644 --- a/xs_unicode.h +++ b/xs_unicode.h | |||
| @@ -22,6 +22,7 @@ | |||
| 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 | int xs_unicode_is_right_to_left(unsigned int cpoint); |
| 25 | int xs_is_emoji(unsigned int cpoint); | ||
| 25 | 26 | ||
| 26 | #ifdef _XS_H | 27 | #ifdef _XS_H |
| 27 | xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); | 28 | xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); |
| @@ -134,6 +135,12 @@ static unsigned int xs_unicode_width_table[] = { | |||
| 134 | 0x20000, 0x2fffd, 2 /* more CJK */ | 135 | 0x20000, 0x2fffd, 2 /* more CJK */ |
| 135 | }; | 136 | }; |
| 136 | 137 | ||
| 138 | /* magic number from https://en.wikipedia.org/wiki/Emoji#Unicode_blocks */ | ||
| 139 | int xs_is_emoji(unsigned int cpoint) { | ||
| 140 | /* returns wether the input is an utf8 emoji */ | ||
| 141 | return cpoint > 0x00A9 && cpoint < 0x1ffff; | ||
| 142 | } | ||
| 143 | |||
| 137 | int xs_unicode_width(unsigned int cpoint) | 144 | int xs_unicode_width(unsigned int cpoint) |
| 138 | /* returns the width in columns of a Unicode codepoint (somewhat simplified) */ | 145 | /* returns the width in columns of a Unicode codepoint (somewhat simplified) */ |
| 139 | { | 146 | { |