Method: String#getbyte
- Defined in:
- string.c
#getbyte(index) ⇒ 0 .. 255
returns the indexth byte as an integer.
5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 |
# File 'string.c', line 5646
static VALUE
rb_str_getbyte(VALUE str, VALUE index)
{
long pos = NUM2LONG(index);
if (pos < 0)
pos += RSTRING_LEN(str);
if (pos < 0 || RSTRING_LEN(str) <= pos)
return Qnil;
return INT2FIX((unsigned char)RSTRING_PTR(str)[pos]);
}
|