On 10/21/2010 06:21 PM, Bruno Haible wrote:
oddly enough, that doesn't include ja_JP; maybe the configure test that
learned whether ja_JP exists is broken?
Yes, it's indicating that test whether the ja_JP locale is supported is
incomplete. Can you run this program, please, and report the output?
============================== foo.c ===============================
#include <locale.h>
#include <time.h>
#include <langinfo.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <locale.h>
struct tm t;
char buf[16];
int main ()
{
int ret;
char *loc;
const char *p;
loc = setlocale (LC_ALL, "ja_JP");
if (loc != NULL)
fprintf (stderr, "setlocale succeeded -> %s\n", loc);
{
const char *cs = nl_langinfo (CODESET);
if (cs != NULL)
fprintf (stderr, "nl_langinfo (CODESET) = |%s|\n", cs);
}
fprintf (stderr, "MB_CUR_MAX = %d\n", (int) MB_CUR_MAX);
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
ret = strftime (buf, sizeof (buf), "%B", &t);
fprintf (stderr, "strftime -> %d\n", ret);
if (ret >= 2)
{
for (p = buf; *p != '\0'; p++)
fprintf (stderr, " %02X", (unsigned char) *p);
fprintf (stderr, "\n");
}
{
wchar_t wc = (wchar_t) 0xBADFACE;
ret = mbtowc (&wc, "\306\374\313\334\270\354>", 2);
fprintf (stderr, "mbtowc -> %d %04X\n", ret, wc);
}
return 0;
}
=========================================================================
$ locale -a
C
en_US.OPTU-8
en_US.UTF-8
POSIX
$ locale -m
UTF-8
ISO_646.irv:1991
$ ./foo
setlocale succeeded -> en_US.UTF-8
nl_langinfo (CODESET) = |UTF-8|
MB_CUR_MAX = 5
strftime -> 8
46 65 62 72 75 61 72 79
mbtowc -> 1 EFC6
Yikes! setlocale() is busted when handed an unrecognized locale, in that
it falls back to a completely different locale rather than failing!
--
Eric Blake ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org