nl_langinfo(CODESET) question

Jakub Jelinek jakub@redhat.com
Mon Apr 2 02:11:00 GMT 2001


Hi!

If setlocale does not find locale with the requested charset, then it just
uses the charset stored in the locale, eventhough libc is able to
transliterate.
I'm wondering whether
setlocale (LC_ALL, "cs_CZ.UTF-8");
shouldn't result in nl_langinfo(CODESET) == "UTF-8" as opposed to
"ISO-8859-2" even if the installed locale is latin2 only.
I know I can use $OUTPUT_CHARSET, am just wondering what's the proper
behaviour of setlocale in this case.
I've tried this on Solaris and if I specify a codeset that is not installed
for a selected locale, nl_langinfo(CODESET) returns "646" as opposed to e.g.
"ISO8859-2" which it returns otherwise.

Or do all programs which wonder about the character set used have to:
charset = getenv("OUTPUT_CHARSET"); if (!charset) charset = nl_langinfo(CODESET);
?

	Jakub



More information about the Libc-hacker mailing list