Using bitwise operations on strings (characters)
Convert letter to lowercase:
ORby space =>(x | ' ')- Result is always lowercase even if letter is already lowercase
- eg.
('a' | ' ') => 'a';('A' | ' ') => 'a'
Convert letter to uppercase:
ANDby underline =>(x & '_')- Result is always uppercase even if letter is already uppercase
- eg.
('a' & '_') => 'A';('A' & '_') => 'A'
Invert letter’s case:
XORby space =>(x ^ ' ')- eg.
('a' ^ ' ') => 'A';('A' ^ ' ') => 'a'
Letter’s position in alphabet:
ANDbychr(31)/binary('11111')/(hex('1F')=>(x & "\x1F")- Result is in 1..26 range, letter case is not important
- eg.
('a' & "\x1F") => 1;('B' & "\x1F") => 2
Get letter’s position in alphabet (for Uppercase letters only):
ANDby?=>(x & '?')orXORby@=>(x ^ '@')- eg.
('C' & '?') => 3;('Z' ^ '@') => 26
Get letter’s position in alphabet (for lowercase letters only):
XORby backtick/chr(96)/binary('1100000')/hex('60')=>(x ^ '`')- eg.
('d' ^ '`') => 4;('x' ^ '`') => 25
Note: using anything other than the english letters will produce garbage results