We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi how can you do a case insensitive string compare ? i'm using uvision3 , c51 version 8. the string.h don't know stricmp or strlwr. can i compile my own function ?
thanks gamba
it seems that the C51 is not supporting any function of lower or upper case convert.
Assumed that you are using the ASCII code, then converting between upper and lower case is a simple matter of adding or subtracting an offset from the character.
For example:
'A' = 0x41 'a' = 0x61 'a' - 'A' = 0x20
So in order to convert an upper case letter to lower case, just add 0x20. To convert lower to upper case, just subtract 0x20. Of course, you need to make sure that the character in question is actually a letter and not some other character, or you'll convert your string to garbage.
en.wikipedia.org/.../Ascii