Red Hat Bugzilla – Bug 1313818
Have setlocale fallback to C.UTF-8 before C/POSIX.
Last modified: 2017-02-28 04:55:26 EST
In Fedora we guarantee a C.UTF-8 locale.
In order to support more applications that require C.UTF-8 and may be installed on systems with few or no locales, we must support the case where the application calls setlocale (LC_ALL, ""); and doesn't check the return code to make sure they have a UTF-8 capable locale.
* Review the differences between C.UTF-8 and C/POSIX
* Change setlocale code to try C.UTF-8 loading before falling back to the builtin C/POSIX locales.
This would fix several of the failure modes we saw during the glibc language pack split up.
But do you really want to do that unconditionally? What if the LC_ALL env var (or others) request instead some 8-bit or other non-UTF-8 locale? Getting C.UTF-8 instead of C would be certainly surprising and undesirable.
I think we should have a small table of well-known UTF-8 locale names, and use C.UTF-8 only if the locale is known as a UTF-8 locale. This would help secondary locale implementations which implement their own charset conversion, but rely on nl_langinfo (CODESET) to get the current charset, too.
We already parse the names of the locales, canonicalizing UTF-8 vs. utf-8 etc., don't we? Thus perhaps we could just recognize that and handle the *.UTF-8/*.utf-8 (perhaps with suffixes) locales that way; not sure if we have any UTF-8 locales without that suffix, those would need to be special cased.
(In reply to Jakub Jelinek from comment #3)
> We already parse the names of the locales, canonicalizing UTF-8 vs. utf-8
> etc., don't we? Thus perhaps we could just recognize that and handle the
> *.UTF-8/*.utf-8 (perhaps with suffixes) locales that way; not sure if we
> have any UTF-8 locales without that suffix, those would need to be special
This is a great idea. My initial idea was simply a strawman proposal to start the discussion of what we should and should not do.
We could and should certainly start with something like this since the motivating use-case is likely *_*.UTF-8 locales that don't exist and then cause gnome-terminal to fail to start (gnome-terminal won't start without a UTF-8 locale, see bug 1312960, and this is intended behaviour).
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.