I can't seem to figure out a bitmask for converting both upper case and lower case letters to upper case. I know I can use XOR 00100000 for converting lowercase to uppercase but this would not work if I XOR an upper case letter with 00100000 back to the same upper case letter. Is there a way to do this?
Asked
Active
Viewed 331 times
1
-
You are mistaken, the XOR works the same in both directions. – Mark Ransom Nov 01 '20 at 01:08
-
Of course you must confirm that the character is a letter before you apply the XOR. – Mark Ransom Nov 01 '20 at 01:09
-
Hmm correct me if I'm wrong but when I try to convert 'A' (01000001) back to 'A' (01000001) itself by XOR-ing 00100000 it becomes 01100001 ('a'). Is there any way in which I can use one bitmask that is capable of converting any lowercase letter to uppercase like 'a' to 'A' and 'A' to 'A' (an uppercase letter back to itself)? – Han Nov 01 '20 at 05:23
-
No, that's not how XOR works. I think you're looking for AND. And you'll still want to make sure the character is a letter before you do this. – Mark Ransom Nov 01 '20 at 15:57