From 0d9bbb74c6de959ab7c6b93b7a97f9f2e643e8e8 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Fri, 5 Dec 2025 22:36:10 -0700 Subject: replace oversized libutf with smaller version this is taken from one of my other projects. there was no reason for there to be 2x the code tests checking for surrogate characters and non characters were removed. I see no reason why the user shouldn't be allowed to insert those characters in text (they exist in the standard). Also, in the case of non-characters only the first two were being checked and not the other 64. --- vis.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 5b5ce2f..bd7bc2a 100644 --- a/vis.c +++ b/vis.c @@ -11,10 +11,11 @@ #include "ui.h" #include "vis-subprocess.h" +#include "util.c" + #include "array.c" #include "buffer.c" #include "event-basic.c" -#include "libutf.c" #include "map.c" #include "sam.c" #include "text.c" @@ -1017,13 +1018,15 @@ long vis_keys_codepoint(Vis *vis, const char *keys) { return -1; } -bool vis_keys_utf8(Vis *vis, const char *keys, char utf8[static UTFmax+1]) { - Rune rune = vis_keys_codepoint(vis, keys); - if (rune == (Rune)-1) - return false; - size_t len = runetochar(utf8, &rune); - utf8[len] = '\0'; - return true; +bool vis_keys_utf8(Vis *vis, const char *keys, char utf8[4+1]) +{ + uint32_t cp = vis_keys_codepoint(vis, keys); + bool result = cp != -1; + if (result) { + size_t len = utf8_encode((unsigned char *)utf8, cp); + utf8[len] = 0; + } + return result; } typedef struct { -- cgit v1.2.3