This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Case Insensitive compare

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

Parents
  • 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

Reply
  • 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

Children
No data