Date: Thu, 18 Dec 1997 12:26:09 +0100 From: "Jose M. Alcaide" <jose@we.lc.ehu.es> To: freebsd-questions@FreeBSD.ORG Subject: should isprint(3) be affected by locale settings ? Message-ID: <34990851.5D20F3AD@we.lc.ehu.es>
next in thread | raw e-mail | index | archive | help
Hi, I would like to know if the locale setting should affect the behavior of isprint(3). I'm very confused about this. The setlocale(3) manpage says: ... LC_CTYPE Set a locale for the ctype(3), mbrune(3), multibyte(3) and rune(3) functions. This controls recognition of upper and lower case, alphabetic or non-alphabetic characters, and so on. The real work is done by the setrunelocale() function. ... >From this we might follow that the locale setting affects isprint(). However, nothing in the ctype(3) or isprint(3) manual pages does any reference to the locale. I have written a tiny program that tests isprint() after calling setlocale(): ------------------------- #include <stdio.h> #include <ctype.h> #include <locale.h> main() { char c, *s; printf("Old locale: %s\n", setlocale(LC_CTYPE, NULL)); if ((s = setlocale(LC_CTYPE, "")) == NULL) { fprintf(stderr, "setlocale() failed.\n"); exit(1); } else printf("New locale: %s\n", s); printf("Type any string ended by RETURN: "); while ((c = getchar()) != '\n') printf("%c: %s\n", c, isprint(c) ? "PRINTABLE" : "UNPRINTABLE"); exit(0); } ------------------------- The execution of this program yields the following results: jose@tiburon[~]$ ./locale Old locale: C New locale: es_ES.ISO_8859-1 Type any string ended by RETURN: aeiouáéíóú a: PRINTABLE e: PRINTABLE i: PRINTABLE o: PRINTABLE u: PRINTABLE á: UNPRINTABLE é: UNPRINTABLE í: UNPRINTABLE ó: UNPRINTABLE ú: UNPRINTABLE The accented vocals are legal ISO-8859-1 characters, but isprint() says that they are unprintable, even after setting the locale. My question is: is this the normal behavior of isprint()? Thanks, --JM ----------------------------------------------------------------------- Jose M. Alcaide | mailto:jose@we.lc.ehu.es Universidad del Pais Vasco | http://www.we.lc.ehu.es/~jose Dpto. de Electricidad y Electronica | Facultad de Ciencias - Campus de Lejona | Tel.: +34-4-4647700 x2624 48940 Lejona (Vizcaya) - SPAIN | Fax: +34-4-4858139 ----------------------------------------------------------------------- "Go ahead... make my day." - H. Callahan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?34990851.5D20F3AD>