From: Xavier Noria Date: 2010-04-18T01:41:30+09:00 Subject: Re: what is String#ord? On Sat, Apr 17, 2010 at 5:35 PM, Xavier Noria wrote: > Ruby 1.9 docs for String#ord say: > >    Return the Integer ordinal of a one-character string. > > What does that mean? Check for example > >    "×".ord # => 215 >    "×".bytes.to_a # => [195, 151] Trial and error suggests it is the code of the character in the encoding of the string: euro = "\u20AC" euro.ord.to_s(16) # => "20ac" euro.encode("iso-8859-15").ord.to_s(16) # => "a4" That is what the source code suggests also: 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); }