Thread: bitmask

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    3

    bitmask

    Can anyone tell me how to use a bitmask to convert uppercase letters to lowercase thank you

  2. #2
    Registered User
    Join Date
    Aug 2001
    Location
    computers/ theatre, travelingstudentL>- Northern California NativeNorthern California3D&Tie-DyeStudent1>. Admirer of C Bangalore Net surfingTeacher >/ >0 nagpurteaching >1  >2
    Posts
    61
    Try one of these:
    tolower(int); I believe it is defined in types.h
    or
    char tolower(char in) {
    if(in >= 'A' && in <= 'Z')
    return in + 'a' - 'A';
    else return in;
    }

    In the ASCII character set, upper case is before lower case, so the difference between the an upper case and its lower case counter part is 'a' - 'A'.

    You can use a bit mask if necessary, but it will be a little more complicated. Think of how you would add and subtract two bits together using only boolean operators. I have done it in the past a bit at a time.

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Do an OR operation on the uppercase letter with a bitmask of hex 20.

    char bitmask = 0x20;

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    Thank you. I'll try that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. get visible mouse cursor height
    By eXistenZ in forum Windows Programming
    Replies: 10
    Last Post: 09-05-2008, 09:46 PM
  2. Binary Converter - Various stupid string issues :p
    By polarpete in forum C++ Programming
    Replies: 7
    Last Post: 08-21-2005, 02:46 PM