From owner-freebsd-questions Wed Nov 29 14: 2:34 2000 Delivered-To: freebsd-questions@freebsd.org Received: from privatecube.privatelabs.com (unknown [63.114.185.254]) by hub.freebsd.org (Postfix) with ESMTP id BF32037B400 for ; Wed, 29 Nov 2000 14:02:30 -0800 (PST) Received: from misha.privatelabs.com (root@misha.plten [10.0.0.106]) by privatecube.privatelabs.com (8.9.3/8.9.2) with ESMTP id RAA17287 for ; Wed, 29 Nov 2000 17:22:02 -0500 Received: (from mi@localhost) by misha.privatelabs.com (8.11.0/8.9.3) id eATM2UP54864 for questions@freebsd.org; Wed, 29 Nov 2000 17:02:30 -0500 (EST) (envelope-from mi) From: Mikhail Teterin Message-Id: <200011292202.eATM2UP54864@misha.privatelabs.com> Subject: setting locale To: questions@freebsd.org Date: Wed, 29 Nov 2000 17:02:30 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-u Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello! I'm having a strange problem experimenting. I thought, that by using setlocale(LC_ALL, NULL) I will get whatever the current setting for LANG (or LC_ALL) is in the environment. But as this simple program illustrates, it is not the case: #include #include int main(int argc, char *argv[]) { char *locale; unsigned char b = argv[argc-1][0]; locale = setlocale(LC_ALL, NULL); printf("In %s ``%c'' (%x) is %san alpha\n", locale, b, b, isalpha(b) ? "" : "not "); } env LANG=ru_SU.KOI8-R ./t l In C ``l'' (6c) is an alpha env LANG=ru_SU.KOI8-R ./t Ë In C ``Ë'' (cb) is not an alpha env LANG=nl_NL.ISO_8859-1 ./t l In C ``l'' (6c) is an alpha How do I make force my C-program use the right locale? I could do something like: setlocale(LC_ALL, getenv("LANG")) but is not that what specifying NULL is supposed to do? Thanks! -mi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message