Hi friends,
In Ruby 1.8.7, we can use “?” operator to find the “character code from a character.?a evaluates to the integer 97. Now we can see some examples via “irb”
Ex: (ruby 1.8.7)
> ?a # it shows character code of "a" => 97
But in Ruby 1.9.2, we can’t use the “?” operator to find character code from a character.In 1.9.7 , syntax “?a” is now the same as "a". There is now an “ord” method of strings to convert a character into its integer code. So we can use the”.ord” method.
Ex: (ruby 1.9.2)
> ?a # it won't show the char code, just show as "a" => "a" > "a".ord # This method ly show char code of "a" in 1.9.7 => 97
Source:
http://en.wikibooks.org/wiki/Ruby_Programming/ASCII
http://rosettacode.org/wiki/Character_codes
