This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
The behavor of printing out libc message catalog without calling setlocale()
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: The behavor of printing out libc message catalog without calling setlocale()
- From: GOTO Masanori <gotom at debian dot or dot jp>
- Date: Tue, 07 Nov 2000 19:14:56 +0900
- Cc: gotom at debian dot or dot jp
Hi, all hackers.
I have a question related with message catalog.
If I run below code sample 1, I get:
(under LANG=C)
test
test2: Success
(under LANG=ja_JP.eucJP)
test
test2: <Japanese Messages, if I installed ja.po catalog
into appropriate place.>
---- sample 1 ----
#include <stdio.h>
#include <locale.h>
main() {
setlocale(LC_ALL, "");
puts("test");
perror("test2");
}
---- sample 1 ----
It's OK. However, if I run sample 2, I get:
(under LANG=C)
test
test2: Success
(under LANG=ja_JP.eucJP)
test
test2: ????
---- sample 2 ----
#include <stdio.h>
main() {
puts("test");
perror("test2");
}
---- sample 2 ----
Now, question:
* Why do we have to call setlocale(), if we use libc's catalog data
in spite of sample 2 does not need ? Is this bug ?
Solution to fix this problem:
1) Call setlocale() anytime if applications use perror()
or something to print out libc's message catalog.
2) Set OUTPUT_CHARSET environment variable to appropriate character
set. In sample 2, OUTPUT_CHARSET have to set to `EUC-JP'.
3) Fix glibc intl functions:
3-1) When applications print out libc's message catalog
in spite of the application does not call setlocale(),
set current nl_langinfo(locale variable (LANG/LC_ALL/LC_MESSAGES))
into domain_file->domainbinding->codeset.
3-2) When applications print out libc's message catalog
in spite of the application does not call setlocale(),
print out libc's original message catalog.
In other words, print out messages as same as LANG=C
(This is Solaris 7's behavior).
4) Vanish libc's translated message catalog! :-)
IMHO, it is inappropriate behavior that we must call
setlocale() in any case we have libc's translated .po file.
So, (3-1) or (3-2) is the best solution to fix it.
Any comments are welcomed.
Regards,
-- GOTO Masanori