Ruby – Get ASCII value
October 30, 2009
Example 1:
puts ?r #=> 114
puts ?a #=> 97
Example 2:
output=”raveendran”
puts output[0] #=>114 ‘value of r’
puts output[1] #=> 97 ‘value of a’
Example 3:
output=”raveendran”
output.each_byte do |a|
puts a
end
>ruby ascii_from_ruby.rb
114
97
118
101
101
110
100
114
97
110
>Exit code: 0
November 16, 2009 at 6:15 am
good work ravee.. keep posting
November 16, 2009 at 6:17 am
Thanks Vaddi.