[Bug 209617] wctomb() is completely broken when UTF-8 locales are used

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri May 20 16:48:14 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209617

--- Comment #2 from jau at iki.fi ---
Right, it was not wctomb() at all that was in fault.
The reason for the misbehavior was...

loc = newlocale (LC_CTYPE_MASK, "fi_FI.UTF-8", LC_GLOBAL_LOCALE);

Other xlocale manual pages mention LC_GLOBAL_LOCALE
pretty much as a generic handle to the process default
locale. The man page for newlocale() doesn't explain
the base locale at all. Neither LC_GLOBAL_LOCALE nor
NULL as the base are explained. It is simply left to
depend on the best guess of the programmer.

It seems that the following modified call works just
fine and also wctomb() after this change...

loc = newlocale (LC_CTYPE_MASK, "fi_FI.UTF-8", NULL);

First of all the meaning of NULL and LC_GLOBAL_LOCALE
should be documented.
Secondly I assume that NULL is taken as a reference to
the current thread locale, whatever it is, not as the
global locale, unless the current thread locale happens
to be the global locale. In such a case it would seem
reasonable to really accept LC_GLOBAL_LOCALE as exactly
what one would expect, the process' global locale
independent of what the current thread locale is.
The current setup is so confusing that I cannot be the
only one getting in trouble with this.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list