commit 4a56b57

grunfink  ·  2025-12-18 08:36:16 +0000 UTC
parent 765cd34
If the emoji starts with &#, convert to an utf-8 string.
1 files changed,  +15, -0
+15, -0
 1@@ -1643,7 +1643,22 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o)
 2             dict = xs_dict_set(dict, "type", "Emoji");
 3             tag = xs_list_append(tag, dict);
 4         }
 5+        else
 6+        if (xs_startswith(emo, "&#")) {
 7+            /* snac default emoji as an HTML entity: decode */
 8+            content = xs_free(content);
 9+
10+            xs *s1 = xs_strip_chars_i(xs_dup(emo), "&#");
11+            unsigned int cpoint = 0;
12+            sscanf(s1, "%u;", &cpoint);
13+
14+            if (cpoint)
15+                content = xs_utf8_cat(xs_str_new(NULL), cpoint);
16+            else
17+                content = xs_dup(emo);
18+        }
19         else {
20+            /* use as it is and hope for the best */
21             xs_free(content);
22             content = xs_dup(emo);
23         }