misc/142173: localeconv: two-byte ascii thousands_sep

Stefan Krah stefan-usenet at bytereef.org
Wed Dec 30 17:10:02 UTC 2009


>Number:         142173
>Category:       misc
>Synopsis:       localeconv: two-byte ascii thousands_sep
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 30 17:10:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Krah
>Release:        8.0-RELEASE-i386
>Organization:
>Environment:
>Description:

The following locales have a two-byte ascii thousands separator. In all cases,
the real separator is followed by an ascii whitespace character. In the attached
test program, the separator is enclosed in XXX:


it_CH.ISO8859-1: XXX. XXX
it_CH.ISO8859-15: XXX. XXX
it_CH.UTF-8: XXX. XXX
it_IT.ISO8859-1: XXX. XXX
it_IT.ISO8859-15: XXX. XXX
it_IT.UTF-8: XXX. XXX
sl_SI.ISO8859-2: XXX  XXX
sl_SI.UTF-8: XXX  XXX



>How-To-Repeat:

Compile the test program. Run:

locale -a | ./printsep
>Fix:


Patch attached with submission follows:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>


int
main(void)
{
	char loc[100];
	size_t n;

	while (fgets(loc, 100, stdin) != NULL) {
		n = strlen(loc);
		if (n > 1) {
			loc[n-1] = '\0';
			setlocale(LC_ALL, loc);
			n = mbstowcs(NULL, localeconv()->thousands_sep, 0);
			if (n > 1) {
				printf("%s: XXX%sXXX\n", loc, localeconv()->thousands_sep);
			}
		}
	}

	return 0;
}



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list