
-----------------------------------
dmitrip
Sat Mar 17, 2007 4:09 pm

Treat Lower case letters the same as Upper case letters using ASCII
-----------------------------------
hello

i am writing a program that has the user input a word and it outputs if the word is a palindrome(reads the same backwards and forwards) or if it is not a palindrome.
Now what i am trying to make it do is treat upper case letters the same as lower case letters, so for example  chr(97) = chr(65) which means that 'a' is the same letter as 'A'
so how could i get the program to treat the letters the same no matter if its upper case or lower case.


thank you very much.

-----------------------------------
CodeMonkey2000
Sat Mar 17, 2007 4:25 pm

RE:Treat Lower case letters the same as Upper case letters using ASCII
-----------------------------------
First look at the ASCII chart (it's some where in the turing reference). Look at the ASCII for lower case letters, and the higher case. Notice a pattern? All the higher case letters are 32 characters lower than their higher case counter part (i.e. chr(65)='A' and chr(97)='a' and the difference is 32 ). Use this idea to solve the problem.

-----------------------------------
[Gandalf]
Sat Mar 17, 2007 5:50 pm

Re: Treat Lower case letters the same as Upper case letters using ASCII
-----------------------------------
Or you can use the Str module built into Turing and convert all your words to either all caps (Str.Upper("hi")) or all lower case (Str.Lower("HI")).  That way when you make your palindrome checks it will treat the letters the same whether or not they are in caps.

-----------------------------------
dmitrip
Sun Mar 18, 2007 1:43 pm

Re: Treat Lower case letters the same as Upper case letters using ASCII
-----------------------------------
this is the bit of code from my program that should convert all the letters into lowercase letters but it but it isnt working.

help will be very appreciteated, and i tried the above but i been trying for an hour now and this is only as far as i got.
thank you







 for i : 1 .. length (word)
        count (i) := word (1 + length (word) - i)
        right (i) := word (i)

    end for

    for i : 1 .. length (word)
  
        if right (i) = count (i) then
            palindrome += 1
            if ord(word(i))>65 and ord (word(i))= 65 and ord (str (x)) = 65 and ord (str (x))  0 and s (1) >= 'a' and s (1)  0 then
        result s (*) + reverse (s (1 .. * -1))
    end if
    result ""
end reverse

fcn isPalindrome (s : string) : boolean
    var upperString := toUpper (s)
    result upperString = reverse (upperString)
end isPalindrome
