diff options
| author | byte <byte@noreply.codeberg.org> | 2026-01-24 21:33:30 +0100 |
|---|---|---|
| committer | byte <byte@noreply.codeberg.org> | 2026-01-24 21:33:30 +0100 |
| commit | bfd071c63826f4d13d48614cedebfb2f8ea20cf6 (patch) | |
| tree | 8cc9b766b88fa66d051e55d65d6694570553a17b /xs_unicode.h | |
| parent | d4137522487235180528281ee64b7c5963f63ebe (diff) | |
| parent | c6b411ac34e80505517bf120153017ec42943d4e (diff) | |
Merge pull request 'master' (#7) from grunfink/snac2:master into main
Reviewed-on: https://codeberg.org/byte/snac2/pulls/7
Diffstat (limited to 'xs_unicode.h')
| -rw-r--r-- | xs_unicode.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xs_unicode.h b/xs_unicode.h index 67b3827..7686dcd 100644 --- a/xs_unicode.h +++ b/xs_unicode.h @@ -1,4 +1,4 @@ -/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ +/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ #ifndef _XS_UNICODE_H @@ -22,6 +22,7 @@ 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); + int xs_is_emoji(unsigned int cpoint); #ifdef _XS_H xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); @@ -134,6 +135,12 @@ static unsigned int xs_unicode_width_table[] = { 0x20000, 0x2fffd, 2 /* more CJK */ }; +/* magic number from https://en.wikipedia.org/wiki/Emoji#Unicode_blocks */ +int xs_is_emoji(unsigned int cpoint) { +/* returns wether the input is an utf8 emoji */ + return cpoint > 0x00A9 && cpoint < 0x1ffff; +} + int xs_unicode_width(unsigned int cpoint) /* returns the width in columns of a Unicode codepoint (somewhat simplified) */ { |