[Bug 295945] Set the ports tree locale to C.UTF-8 in Mk/bsd.port.mk and retire USE_LOCALE
Date: Wed, 10 Jun 2026 14:50:35 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295945
--- Comment #5 from Tijl Coosemans <tijl@FreeBSD.org> ---
(In reply to Robert Clausecker from comment #3)
It looks like the trick to install share/locale/C/LC_MESSAGES/SCHILY_utils.mo
stopped working with gettext 0.23. Gettext treats C.<encoding> as untranslated
now. But you're not using gettext for translation. You're relying on the fact
that gettext calls iconv on translation strings. So, instead of using gettext
you could use iconv directly. However, if I were you I would remove all the
gettext stuff and replace _("Jörg Schilling") and _("Joerg Schilling") with
"J\xc3\xb6rg Schilling". Users that still use ISO8859-1 will see that as
"Jörg Schilling", but that group is shrinking.
The solution with iconv looks something like this: use iconv in main() to
convert the string "J\xf6rg Schilling" from ISO8859-1 to the encoding of the
current locale into some buffer, and then replace _("Jörg Schilling") and
_("Joerg Schilling") everywhere with a pointer to that buffer.
char jorgschilling[64] = {}; /* zero filled */
static const char jorgschilling_src[] = "J\xf6rg Schilling";
main() {
...
setlocale(LC_ALL, "");
...
iconv_t icd = iconv_open("", "ISO8859-1");
char *dst = jorgschilling;
size_t dstlen = sizeof(jorgschilling) - 1;
char *src = jorgschilling_src;
size_t srclen = sizeof(jorgschilling_src) - 1;
iconv(icd, &src, &srclen, &dst, &dstlen);
iconv_close(icd);
...
}
foo() {
printf("%s\n", jorgschilling);
}
--
You are receiving this mail because:
You are on the CC list for the bug.