summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2026-01-26 15:40:35 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2026-01-26 15:40:35 +0100
commit1a285f43ecb6487225d77a0d33dddf2fe0caf819 (patch)
tree9ef38563aaac0f69b9cf9806f85192079c161ab3 /src
parentf61d54e71d63b29e805dc69dc6337f65273440b9 (diff)
Modify fl_utf8toa() to make it account for composed emojis.
Diffstat (limited to 'src')
-rw-r--r--src/fl_utf8.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx
index 81af4a4e7..dd59acc10 100644
--- a/src/fl_utf8.cxx
+++ b/src/fl_utf8.cxx
@@ -1318,8 +1318,13 @@ unsigned fl_utf8toa(const char* src, unsigned srclen,
dst[count] = c;
p++;
} else {
- int len; unsigned ucs = fl_utf8decode(p,e,&len);
- p += len;
+ unsigned ucs = 0x100;
+ int len = fl_utf8len(*p);
+ if (len > 2) p = fl_utf8_next_composed_char(p, e);
+ else {
+ ucs = fl_utf8decode(p,e,&len);
+ p += len;
+ }
if (ucs < 0x100) dst[count] = ucs;
else dst[count] = '?';
}
@@ -1329,9 +1334,11 @@ unsigned fl_utf8toa(const char* src, unsigned srclen,
while (p < e) {
if (!(*p & 0x80)) p++;
else {
- int len;
- fl_utf8decode(p,e,&len);
- p += len;
+ int len = fl_utf8len1(*p);
+ if (len > 2) p = fl_utf8_next_composed_char(p, e);
+ else {
+ p += len;
+ }
}
++count;
}