I’m learning the Ruby language but I have a problem: strings with
Portuguese names are always different.
name = gets.chomp.to_s
puts “Hello João!” if name == “João”
But “name” is always different from “João”. The program only works if I
change it to a version without the character ã.
So I tried to compare the number of bytes and ASCII codes of the two
strings and I concluded this:
-The character “ã” obtained by “gets” has the ASCII code 198 (one
-The character “ã” from the string “João” (last line) has the ASCII code
195 and 163 (two bytes);
-The two strings when printed with “puts” look the same but when
compared with “if” they are different.
How can I solve this? Thanks.