summaryrefslogtreecommitdiff
path: root/xs_unicode.h
diff options
context:
space:
mode:
authorGravatar byte2026-01-24 21:33:30 +0100
committerGravatar byte2026-01-24 21:33:30 +0100
commitbfd071c63826f4d13d48614cedebfb2f8ea20cf6 (patch)
tree8cc9b766b88fa66d051e55d65d6694570553a17b /xs_unicode.h
parentAdded a Follow/Unfollow button next to a new follow notification. (diff)
parentMerge pull request 'add susie-q (qr) to artwork' (#528) from pmjv/snac2:maste... (diff)
downloadsnac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.tar.gz
snac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.tar.xz
snac2-bfd071c63826f4d13d48614cedebfb2f8ea20cf6.zip
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.h9
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 @@
1/* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ 1/* copyright (c) 2022 - 2026 grunfink et al. / MIT license */
2 2
3#ifndef _XS_UNICODE_H 3#ifndef _XS_UNICODE_H
4 4
@@ -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 */
139int xs_is_emoji(unsigned int cpoint) {
140/* returns wether the input is an utf8 emoji */
141 return cpoint > 0x00A9 && cpoint < 0x1ffff;
142}
143
137int xs_unicode_width(unsigned int cpoint) 144int 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{