John Joyce
8/16/2007 8:50:00 PM
On Aug 16, 2007, at 3:36 PM, Adam Shelly wrote:
> On 8/16/07, John Joyce <dangerwillrobinsondanger@gmail.com> wrote:
>> Oops, no, that's not what I need. I can do that.
>> I need to take "I" or "J" or whatever character and convert to hex!
>> or binary
>> (sorry, I'm a little sleepy now)
>>
> like this?
>
>
> irb(main):011:0> s = "A"
> => "A"
> irb(main):012:0> s[0]
> => 65
> irb(main):013:0> c = ?A
> => 65
> irb(main):014:0> s[0].to_s(16)
> => "41"
> irb(main):015:0> c.to_s(16)
> => "41"
> irb(main):016:0> c.to_s(2)
> => "1000001"
>
Hmm... that first technique is useful! Returning elements of a string.