oct()
public
Treats leading characters of str as a string of octal digits (with
an optional sign) and returns the corresponding number. Returns 0 if the
conversion fails.
"123".oct
"-377".oct
"bad".oct
"0377bad".oct
Show source
static VALUE
rb_str_oct(VALUE str)
{
rb_encoding *enc = rb_enc_get(str);
if (!rb_enc_asciicompat(enc)) {
rb_raise(rb_eEncCompatError, "ASCII incompatible encoding: %s", rb_enc_name(enc));
}
return rb_str_to_inum(str, -8, FALSE);
}