C doesn't define whether a "char" is signed or unsigned, so masking makes sure 
that you don't pass in a negative number, and also keeps the value within the 
range supported by the ctype functions (-1 to 255 in most cases - -1 because 
that is the "EOF" character...)

On Oct 18, 2011, at 3:06 PM, Ian MacArthur wrote:

> 
> On 18 Oct 2011, at 19:43, Michael Sweet wrote:
> 
>> In this case I would not use strtol to skip digits, but a simple while loop 
>> instead:
>> 
>>   while (isdigit(*str & 255))
>>     str ++;
>> 
>> (the "& 255" part is necessary to avoid portability issues with UTF-8 
>> strings)
> 
> 
> OK - I'm feeling particularly stupid now: how does masking a byte with 0xFF 
> help? Is it that isdigit() thinks it gets an int, or...
> I'm missing something key here, obviously...
> 
> 
> 
> 
> _______________________________________________
> fltk-dev mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk-dev

_____________
Michael Sweet




_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to