On Sun, May 07, 2000 at 06:04:03PM +0200, srittau wrote:
> The is*() and toupper()/tolower() functions do not work on non-ASCII
> characters, even if LC_CTYPE etc. are set to the correct language used:
Yes they do.
> [EMAIL PROTECTED]:~$ locale
> LANG=de_DE
> LC_CTYPE="de_DE"
> LC_NUMERIC="de_DE"
> LC_TIME="de_DE"
> LC_COLLATE="de_DE"
> LC_MONETARY="de_DE"
> LC_MESSAGES="de_DE"
> LC_ALL=
> [EMAIL PROTECTED]:~$ cat try.c
> #include <ctype.h>
> #include <stdio.h>
>
> int main()
> {
> int c = '�';
> printf("%c: %d\n", c, isprint(c));
>
> return 0;
> }
> [EMAIL PROTECTED]:~$ gcc try.c -o try -Wall
> [EMAIL PROTECTED]:~$ ./try
> �: 0
> [EMAIL PROTECTED]:~$
This is expected behaviour. In the absence of a "setlocale" call the
program's locale is C. To use the locale settings from the environment,
call setlocale(LC_ALL, ""). Observe:
$ locale
LANG=fi_FI
LC_CTYPE="fi_FI"
LC_NUMERIC="fi_FI"
LC_TIME="fi_FI"
LC_COLLATE="fi_FI"
LC_MONETARY="fi_FI"
LC_MESSAGES="fi_FI"
LC_ALL=
$ cat try-orig.c
#include <ctype.h>
#include <stdio.h>
int main()
{
int c = '�';
printf("%c: %d\n", c, isprint(c));
return 0;
}
$ gcc try-orig.c -o try-orig -Wall
$ ./try-orig
�: 0
$ cat try.c
#include <ctype.h>
#include <locale.h>
#include <stdio.h>
int main()
{
int c = '�';
setlocale(LC_ALL, "");
printf("%c: %d\n", c, isprint(c));
return 0;
}
$ gcc try.c -o try -Wall
$ ./try
�: 16384
$
This behaviour is (AFAIK) described in the ISO C standards, and in the
setlocale(3) manual page.
To the maintainer: you may close this bug.
--
%%% Antti-Juhani Kaijanaho % [EMAIL PROTECTED] % http://www.iki.fi/gaia/ %%%
I'm moving IRL on May 2, 2000.
New contact information on the home page