char representation



Hi all,

visiting some sources I saw code fragments that relay on a ascii like internal
character representation:

here just one I've picked up
gtype.c:537:  name_valid = (p[0] >= 'A' && p[0] <= 'Z') || (p[0] >= 'a' && p[0] <= 'z') || p[0] == '_';

the same in the pango package.

on systems such IBM host S/390 running Operating System OS/390 (MVS) the internal character
representation is EBCDIC for which p[0] >= 'A' && p[0] <= 'Z' does not hold
when looking for an uppercase letter.

Generally there is no guarantee that any character range (digits, letters,
...) have consecutive values. There is also no guarantee for 'A' < 'Z'.

The correct way to deal with this is "isupper (c)" or something like this.
I guess g_ascii_isupper() would do this job perfectly, because it is based on
character attributes and not on on their internal representation.

Regards,
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]