From 5f928c4f62b193253c8db3f6bd9523ca84704ded Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 26 Sep 2026 15:54:44 -0500 Subject: [PATCH] Parse U+XXXX to display unicode char and utf8 for codepoint. --- toys/other/ascii.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toys/other/ascii.c b/toys/other/ascii.c index aa498721..afddbe9b 100644 --- a/toys/other/ascii.c +++ b/toys/other/ascii.c @@ -30,7 +30,7 @@ config UNICODE Convert between Unicode code points and UTF-8, in both directions. CODE can be one or more characters (show U+XXXX), hex numbers - (show character), or dash separated range. + (show character), dash separated range, or U+XXXX. */ #define FOR_unicode @@ -60,7 +60,8 @@ void unicode_main(void) // Loop through args, handling range, hex code, or character(s) for (args = toys.optargs; *args; args++) { - if (sscanf(*args, "%x-%x%c", &from, &to, &next) == 2) + if (sscanf(*args, "U+%x", &from)) codepoint(from); + else if (sscanf(*args, "%x-%x%c", &from, &to, &next) == 2) while (from <= to) codepoint(from++); else if (sscanf(*args, "%x%c", &from, &next) == 1) codepoint(from); else for (s = *args; (n = utf8towc(&wc, s, 4)) > 0; s += n) codepoint(wc); -- 2.39.5