From 8dc2e7d2f11aee4e70c3675e4ba6dd255a47e0e4 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Wed, 23 Sep 2026 11:51:44 +0200 Subject: web: ship glibc C.utf8 so the web TUI shows åäö MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cross-built bokftui is static glibc; in the Alpine web image it found no locale data, setlocale() failed and åäö were invalid bytes. The cross build now copies Debian's C.utf8 into the image and the image build runs bokfweb --check-locale, so a TUI without UTF-8 fails the build. Co-Authored-By: Claude Opus 5.5 --- clients/bokfweb.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'clients') diff --git a/clients/bokfweb.c b/clients/bokfweb.c index d04e2d6..cc19826 100644 --- a/clients/bokfweb.c +++ b/clients/bokfweb.c @@ -15,6 +15,7 @@ directly: only Caddy and the wrapper in the same container talk to it. */ #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #include "client.h" #include "log.h" @@ -446,8 +448,30 @@ static void serve(int cfd, struct gate *g) memset(buf, 0, n); /* the body may hold a password */ } -int main(void) +/* `bokfweb --check-locale`, run while the web image is built: bokftui in + the same image needs a UTF-8 locale for åäö, and a statically linked + glibc finds none unless its locale data is installed. Exits 1 without. */ +static int check_locale(void) { + const char *l = setlocale(LC_ALL, ""); + wchar_t w = 0; + mbstate_t st; + memset(&st, 0, sizeof st); + size_t n = mbrtowc(&w, "\xc3\xa5", 2, &st); /* å */ + if (!l || n != 2 || w != 0xE5) { + fprintf(stderr, "bokfweb: no UTF-8 locale (setlocale: %s); bokftui " + "would show no åäö\n", + l ? l : "failed"); + return 1; + } + printf("locale ok: %s\n", l); + return 0; +} + +int main(int argc, char **argv) +{ + if (argc > 1 && strcmp(argv[1], "--check-locale") == 0) + return check_locale(); signal(SIGPIPE, SIG_IGN); const char *lvl = getenv("BOKFWEB_LOG_LEVEL"); log_set_level(lvl ? log_level_from_name(lvl) : LOG_INFO); -- cgit v1.3