[Info-vax] character set translation for language accents

glen herrmannsfeldt gah at ugcs.caltech.edu
Fri Apr 17 17:13:39 EDT 2009


Steven Schweda <sms.antinode at gmail.com> wrote:
> JF Mezei wrote:
 
>> If you program in C, you need to have all character variables declared
>> as "unsigned char" because "signed char" (the default) does cut off high
>> order bits when you print/compare them.
 
> And you've tried this?  I'd like to see that demonstration.
(snip)
 
>    sc = 0xe9;
>    uc = 0xe9;
>    printf( " sc: >%c<, uc: >%c<.\n", sc, uc);
 
> I don't see an obvious difference.  I also wouldn't expect
> one.  "signed" or "unsigned" affects the way the high bit is
> interpreted; neither causes any bits to be lost or ignored.

You do have to be careful, but often it will work.

Note, for example, if you pass a pointer to signed char to
a library routine using unsigned char, most likely it will be fine
and the library routine will do the compare using unsigned char.

Watch, though, for the is... macros, such as isalpha.  Most
are a table lookup which will fail with negative characters.

getchar (getc) normally return EOF as -1, which will cause
problems with the 0xFF character.  If you use them for table
lookup either and with 0xff or use unsigned char.

-- glen




More information about the Info-vax mailing list