G
gelbeiche
I have a question regarding the following
small C program.
#include <locale.h>
int main()
{
char* loc = 0;
char before,after;
int i;
loc = setlocale(LC_ALL,"de_DE.iso88591");
printf("locale:%s\n", loc);
before = 'ä';
printf("decimal value:%d \n",before);
printf("hex value:%x \n",before);
printf("char value:%c \n",before);
i = toupper(before);
printf("i=%i\n",i);
after = (char) i;
printf("decimal value:%d \n",after);
printf("hex value:%x \n",after);
printf("after=%c\n",after);
}
At Linux the output of the program looks ok.
It converts the German umlaut 'ä' to the upper
'Ä'.
output at linux:
locale:de_DE.iso88591
decimal value:-28
hex value:ffffffe4
char value:ä
i=196
decimal value:-60
hex value:ffffffc4
after=Ä
But now look at the output at HPUX (compiled
with HPUXs C-compiler cc):
locale:de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591
decimal value:-28
hex value:ffffffe4
char value:ä
i=0
decimal value:0
hex value:0
after=
The locale is multiple times printed
and the character is not converted properly.
When I call `locale -a` at HPUX the de_DE.iso88591
locale is listed.
What is the reason for this misbehaviour ?
small C program.
#include <locale.h>
int main()
{
char* loc = 0;
char before,after;
int i;
loc = setlocale(LC_ALL,"de_DE.iso88591");
printf("locale:%s\n", loc);
before = 'ä';
printf("decimal value:%d \n",before);
printf("hex value:%x \n",before);
printf("char value:%c \n",before);
i = toupper(before);
printf("i=%i\n",i);
after = (char) i;
printf("decimal value:%d \n",after);
printf("hex value:%x \n",after);
printf("after=%c\n",after);
}
At Linux the output of the program looks ok.
It converts the German umlaut 'ä' to the upper
'Ä'.
output at linux:
locale:de_DE.iso88591
decimal value:-28
hex value:ffffffe4
char value:ä
i=196
decimal value:-60
hex value:ffffffc4
after=Ä
But now look at the output at HPUX (compiled
with HPUXs C-compiler cc):
locale:de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591 de_DE.iso88591
decimal value:-28
hex value:ffffffe4
char value:ä
i=0
decimal value:0
hex value:0
after=
The locale is multiple times printed
and the character is not converted properly.
When I call `locale -a` at HPUX the de_DE.iso88591
locale is listed.
What is the reason for this misbehaviour ?