PDA

View Full Version : ascii code and accents



JMD
January 3rd, 2005, 15:58
hi,

When I type this :


printf("%c, %s, %c, %i\n", 133, "à", "à", "à");


the result is :


à, Ó, è, 4199050


In extended ascci table, the code of 'à' is 133.

How can I have the (extended) ascii code from a char string with accents ?

My main goal is to use the ascii code to find letters in a texture to write a text with accent on screen.

Doas another methode exist ?

Thanks

c99koder
January 3rd, 2005, 17:13
you need to use single quotes around your characters, not double quotes.

'c' is a character, while "s" is a string (pointer to an array of characters).

-Sam

JMD
January 4th, 2005, 06:24
Thanks Sam.

But I tried this


printf("%c, %s, %c, %i\n", 133, "à", 'à' , 'à');

and the return is :


à, Ó, Ó, -32


???

GPF
January 4th, 2005, 11:39
i ran into a similiar problem and this is what I used.


char a='à';
int j=(int)a;
int i=(int)a &0xFF;
printf(" %c = %d not %d \n",a,i,j);

and here is the output


à = 224 not -32

Troy

JMD
January 4th, 2005, 16:09
works fine :)

Thanks.