From: Brian Candler Date: 2009-07-06T16:58:58+09:00 Subject: Re: Convert an Character to the ASCII Character Code Aaron Patterson wrote: > On Mon, Jul 06, 2009 at 07:32:38AM +0900, John Gregory wrote: >> >> I would still like to know how to get the same results using my current >> version. > > How about this: > > "e".getbyte(0) > > and: > > "e".getbyte(0).to_f Or: irb(main):001:0> "e".ord => 101 This is a bit different, as it works in terms of codepoints (characters) rather than bytes. This won't make a difference if you are using US-ASCII only. irb(main):003:0> "棚".encoding => # irb(main):004:0> "棚".ord => 234 irb(main):005:0> "棚".bytesize => 2 irb(main):006:0> "棚".getbyte(0) => 195 irb(main):007:0> "棚".getbyte(1) => 170 -- Posted via http://www.ruby-forum.com/.