Date: Wed, 29 Nov 2000 17:02:30 -0500 (EST) From: Mikhail Teterin <mi@privatelabs.com> To: questions@freebsd.org Subject: setting locale Message-ID: <200011292202.eATM2UP54864@misha.privatelabs.com>
next in thread | raw e-mail | index | archive | help
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 <locale.h> #include <stdio.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011292202.eATM2UP54864>