30 May 2009 02:29
setlocale() and codepage (3.3.6)
Alex Taylor <mail.me <at> reply.to.address>
2009-05-30 00:29:02 GMT
2009-05-30 00:29:02 GMT
Using GCC 3.3.6, I don't know if this applies to later versions...
Calling
char *loc = setlocale(LC_TIME, "")
is supposed to set the time conventions to the current locale defined in
the environment, which it does.
However, it seems to automatically append the codepage specifier ISO8859-1,
regardless of what the current codepage is.
For instance, running under Japanese OS/2, this code:
char *loc = setlocale(LC_TIME, "")
printf("Locale: %s\n", loc );
reports:
ja_JP.ISO8859-1
which isn't very useful, as ISO8859-1 doesn't support Japanese text. If
I then try to print a localized time string from strftime, the Japanese
characters are all replaced by 0x1A (even though the current process
codepage supports them).
Is there any graceful way to tell setlocale() to use the current process
codepage?
RSS Feed