Charles Mills wrote:

It's clearly doing everything in ASCII:

strcasecmp("Z", "0") 122
It's interesting. I use the same compare function for both a sort and for a
binary search, so it all works correctly -- it's just not working the way I
think it is.

Charles

I find that very odd...

strcasecmp() is obliged to convert all upper-case letters into lower-case
for the comparison.

Lower-case 'z' in EBCDIC is 0xa9, '0' in EBCDIC is 0xf0.  0xA9 is less
than 0xF0; so I would expect strcasecmp() to return a value less than
zero.

But - as you point out - in ASCII, 'z' is 0x7a, and '0' is 0x30.  0x7a is
greater than 0x30, so on an ASCII platform I would expect this to return
a positive value (note that 0x7a - 0x30 is 74 - not the 122 that IBM returned,
although both are positive.)

IBM must be mapping the values to some abstract code-points and then
subtracting those...

It _would_ mean that the strcasecmp() results are consistent between
ASCII and EBCDIC environments... which might sometimes be a desirable
characteristic - and other times not...

 - Dave Rivers -

--
[email protected]                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to