locale Verwirrungen

From: Ulrich Spoerlein <q(at)uni.de>
Date: Fri, 20 Feb 2004 00:04:17 +0100

Moin,

I versuche gerade herrauszufinden, warum 'ps' darauf besteht am/pm
auszugeben, obwohl ich z.B. LC_TIME=de_DE.ISO8859-1 definiert habe.

Hierzu hab ich mir den Source von src/bin/ps/print.c angeguckt und dann
ein kleines Testprogramm geschrieben.

1. Frage: Wenn ich LC_TIME oder LC_ALL als Umgebungsvariable setze
aendert sich an der Ausgabe von nl_langinfo() nichts. Warum?

2. Frage: Kann mir bitte jemand die folgende Ausgabe erklaeren?:
% cc -o ampm ampm.c && ./ampm
de_DE:
Date: %d.%m.%Y
Time: %H:%M:%S
AMPM: %I:%M:%S %p
en_US:
Date: %m/%d/%Y
Time: %H:%M:%S
AMPM: %I:%M:%S %p

Date scheint ja ok zu sein, aber seit wann hat en_US eine 24h Uhr (%H)
und warum wird AMPM im Fall von de_DE ueberhaupt zurueckgegeben? In
nl_langinfo(3) steht:
     In all locales, nl_langinfo() returns a pointer to an empty string
     if item contains an invalid setting.

Hier das Testprogramm:
#include <langinfo.h>
#include <locale.h>
#include <stdlib.h>

int
main(void) {
        setlocale(LC_TIME, "de_DE.ISO8859-1");
        printf("de_DE:\n");
        printf("Date: %s\n", nl_langinfo(D_FMT));
        printf("Time: %s\n", nl_langinfo(T_FMT));
        printf("AMPM: %s\n", nl_langinfo(T_FMT_AMPM));
        setlocale(LC_TIME, "en_US.ISO8859-1");
        printf("en_US:\n");
        printf("Date: %s\n", nl_langinfo(D_FMT));
        printf("Time: %s\n", nl_langinfo(T_FMT));
        printf("AMPM: %s\n", nl_langinfo(T_FMT_AMPM));
        return (0);
}

Achja, das ganze wurde unter 4.9 und 5.2 getestet.

Ulrich Spörlein

-- 
PGP Key ID: F0DB9F44				Get it while it's hot!
PGP Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated".	-- Ken Thompson

To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Fri 20 Feb 2004 - 00:11:28 CET

search this site