fix: terminate XIM UTF-8 text runs

This commit is contained in:
2026-08-12 16:43:57 +09:00
parent 71af269efe
commit 4e8720a40d
3 changed files with 48 additions and 12 deletions

View File

@@ -32,6 +32,26 @@ checktext(const char *s)
free(ct);
}
static void
checkfallback(void)
{
static const char s[] = "😀";
static const char want[] = "\033%G😀\033%@";
char *ct, *utf8;
size_t clen, ulen;
ct = ximutf8compound(s, sizeof s - 1, &clen);
assert(ct != NULL);
assert(clen == sizeof want - 1);
assert(memcmp(ct, want, clen) == 0);
utf8 = xcb_compound_text_to_utf8(ct, clen, &ulen);
assert(utf8 != NULL);
assert(ulen == sizeof s - 1);
assert(memcmp(utf8, s, ulen) == 0);
free(utf8);
free(ct);
}
int
main(void)
{
@@ -61,5 +81,6 @@ main(void)
checktext("😀");
checktext("❤️");
checktext("A😀한");
checkfallback();
return 0;
}