each_byte()
public
Passes each byte in str to the
given block.
"hello".each_byte {|c| print c, ' ' }
produces:
104 101 108 108 111
Show source
/*
* call-seq:
* str.each_byte {|fixnum| block } => str
*
* Passes each byte in <i>str</i> to the given block.
*
* "hello".each_byte {|c| print c, ' ' }
*
* <em>produces:</em>
*
* 104 101 108 108 111
*/
static VALUE
rb_str_each_byte(str)
VALUE str;
{
long i;
for (i=0; i<RSTRING(str)->len; i++) {
rb_yield(INT2FIX(RSTRING(str)->ptr[i] & 0xff));
}
return str;
}