« Return to Thread: [ruby-list:46140] 文字変換について

[ruby-list:46145] Re: 文字変換について

by rubikitch :: Rate this Message:

Reply to Author | View in Thread

From: "Hideo Konami" <konami@...>
Subject: [ruby-list:46141] Re: 文字変換について
Date: Fri, 3 Jul 2009 08:36:54 +0900

るびきちです。

> なお 'a' のアスキーコードは 'a'[0] でいいです。

それはRuby 1.8の話です。

RUBY_VERSION  # => "1.8.7"
'a'[0]        # => 97

Ruby 1.9では1文字の文字列を返します。

RUBY_VERSION  # => "1.9.1"
'a'[0]        # => "a"

# each_byteでバイトのenumeratorを作成する。(Ruby 1.8.7以降)
"abc".each_byte.first           # => 97

--
rubikitch
Blog: http://d.hatena.ne.jp/rubikitch/
Site: http://www.rubyist.net/~rubikitch/
Twit: http://twitter.com/rubikitch/

 « Return to Thread: [ruby-list:46140] 文字変換について