hex()
public
Treats leading characters from str as a string of hexadecimal
digits (with an optional sign and an optional 0x) and returns the
corresponding number. Zero is returned on error.
"0x0a".hex
"-1234".hex
"0".hex
"wombat".hex
Show source
static VALUE
rb_str_hex(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, 16, FALSE);
}