From: Rob L.
I can’t understand how to access the first byte from
a string (a series of 8 bit bytes I believe). There don’t seem to be
bit-shift operators in Ruby for a string - could anybody
advise how I go about this ?
Strings in Ruby are, as you say, series of 8-bit bytes. The String#
operator when called with a single integer index returns the numeric
value of the requested byte:
irb(main):001:0> s = “\xf7\x23”