instance method
String#ord
() -> ::Integer
ord → integer
string.c
View on GitHub ↗
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);
}
Returns the integer ordinal of the first character of self:
Example
'h'.ord # => 104 'hello'.ord # => 104 'тест'.ord # => 1090 'こんにちは'.ord # => 12371
Related: see Converting to Non-String.