Bug 233244 - mbtowc and wctomb are broken for all single-byte locales (except for C)
Summary: mbtowc and wctomb are broken for all single-byte locales (except for C)
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2018-11-15 21:24 UTC by Yuri Pankov
Modified: 2018-11-15 21:24 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Pankov freebsd_committer 2018-11-15 21:24:25 UTC
Looking at bug #211762, I noticed that mbtowc() and wctomb() don't do any conversion when LC_CTYPE is a single-byte locale (e.g. lv_LV.ISO8859-13 or ru_RU.KOI8-R), and simply fill the output buffer with the input value.

POSIX defines mbtowc, for example, as "mbtowc - convert a character to a wide-character code", and "The behavior of this function is affected by the LC_CTYPE category of the current locale.", so there's nothing pointing to single-byte locales being any special and not requiring conversion.

glibc (as found in Debian GNU/Linux) correctly converts characters from single-byte-locales-other-than-C to corresponding wide ones.  OTOH, single-byte locales are losing their significance, and fixing this could be just not worth the effort required for testing the changes, more so as this doesn't seem to be reported previously.