[Bug 234010] Lack of Unicode support in strfmon breaks monitary formatting

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Dec 14 11:31:16 UTC 2018


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

            Bug ID: 234010
           Summary: Lack of Unicode support in strfmon breaks monitary
                    formatting
           Product: Base System
           Version: 11.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: misc
          Assignee: bugs at FreeBSD.org
          Reporter: jon at herrskogen.se

This bug was manifested when using the PHP function money_format and
LC_MONETARY sv_SE.UTF-8 to format some currency. Instead of a space as the
thousand separator, it was a ?-symbol. I'm not very good at this, but this is
what I have come up with:

* FreeBSD is retrieving locale data from http://cldr.unicode.org
* In at least sv_SE.UTF-8, the value ending up as monitary thousand separator
is a unicode character (C2 A0).
* localeconv is fetching the data in /usr/share/locale/sv_SE.UTF-8/LC_MONETARY
and returning a pointer.
* __format_grouped_double (with the description "convert double to ASCII") is
calling localeconv to fetch the thousand separator and seems to only use the
first byte (C2).

* strfmon is calling __format_grouped_double to format the grouping of the
string and returns bad strings when using locales with unicode characters.


How to reproduce:

setlocale(LC_MONETARY, "sv_SE.UTF-8");
int i;
strfmon(buf, sizeof(buf), "%i", money);
printf("%s\n", buf);
for(i=0; i<sizeof(buf); i++) {
        printf("%2d - %i \n", i, buf[i]);
}

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


More information about the freebsd-bugs mailing list