From owner-freebsd-questions Thu Dec 18 03:31:38 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id DAA10785 for questions-outgoing; Thu, 18 Dec 1997 03:31:38 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from polaris.we.lc.ehu.es (polaris.we.lc.ehu.es [158.227.6.43]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id DAA10764 for ; Thu, 18 Dec 1997 03:31:32 -0800 (PST) (envelope-from jose@we.lc.ehu.es) Received: from we.lc.ehu.es by polaris.we.lc.ehu.es (SMI-8.6/SMI-SVR4) id MAA00845; Thu, 18 Dec 1997 12:26:09 +0100 Message-ID: <34990851.5D20F3AD@we.lc.ehu.es> Date: Thu, 18 Dec 1997 12:26:09 +0100 From: "Jose M. Alcaide" Organization: Universidad del Pais Vasco - Dpto. de Electricidad y Electronica X-Mailer: Mozilla 4.04 [en] (X11; I; FreeBSD 2.2.5-RELEASE i386) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG Subject: should isprint(3) be affected by locale settings ? Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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 #include #include 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