Method: String#ord

Defined in:
string.c

#ordInteger

Returns the Integer ordinal of a one-character string.

"a".ord         #=> 97

Returns:



9802
9803
9804
9805
9806
9807
9808
9809
# File 'string.c', line 9802

static VALUE
rb_str_ord(VALUE s)
{
    unsigned int c;

    c = rb_enc_codepoint(RSTRING_PTR(s), RSTRING_END(s), STR_ENC_GET(s));
    return UINT2NUM(c);
}