Ruby 1.8.7 Reference Manual > All Libraries > Builtin Library > class String > bytes

instance method String#bytes

each_byte {|byte| ... } -> self
bytes {|byte| ... } -> self
each_byte -> Enumerable::Enumerator
bytes -> Enumerable::Enumerator

文字列の各バイトに対して繰り返します。

例:

"str".each_byte do |byte|
  p byte
end
    # => 115
    # => 116
    # => 114

[SEE_ALSO] String#unpack