From: Ryan Davis Date: 2010-12-04T06:19:07+09:00 Subject: Re: ascii ?c "c"[0] "c".ord.chr question On Dec 3, 2010, at 12:39 , Stu wrote: > I was curious why the prefix ? for ascii code was removed in 1.9.x? It wasn't removed, it just changed what it returns to work with multibyte chars: > multiruby -e 'p ?c' > > VERSION = 1.8.6-p399 > CMD = ~/.multiruby/install/1.8.6-p399/bin/ruby -e p ?c > > 99 > > RESULT = 0 > > VERSION = 1.8.7-p302 > CMD = ~/.multiruby/install/1.8.7-p302/bin/ruby -e p ?c > > 99 > > RESULT = 0 > > VERSION = 1.9.1-p129 > CMD = ~/.multiruby/install/1.9.1-p129/bin/ruby -e p ?c > > "c" > > RESULT = 0 > > VERSION = 1.9.2-p0 > CMD = ~/.multiruby/install/1.9.2-p0/bin/ruby -e p ?c > > "c" > > RESULT = 0 > > TOTAL RESULT = 0 failures out of 4 > > Passed: 1.9.2-p0, 1.9.1-p129, 1.8.6-p399, 1.8.7-p302 > Failed: If you want compatibility between 1.8 and 1.9, I suggest the following: > 505 % multiruby -e 'class String; def ord; self[0]; end unless "".respond_to? :ord; end; p "c".ord' > > VERSION = 1.8.6-p399 > CMD = ~/.multiruby/install/1.8.6-p399/bin/ruby -e 'class String; def ord; self[0]; end unless "".respond_to? :ord; end; p "c".ord' > > 99 > > RESULT = 0 > > VERSION = 1.8.7-p302 > CMD = ~/.multiruby/install/1.8.7-p302/bin/ruby -e 'class String; def ord; self[0]; end unless "".respond_to? :ord; end; p "c".ord' > > 99 > > RESULT = 0 > > VERSION = 1.9.1-p129 > CMD = ~/.multiruby/install/1.9.1-p129/bin/ruby -e 'class String; def ord; self[0]; end unless "".respond_to? :ord; end; p "c".ord' > > 99 > > RESULT = 0 > > VERSION = 1.9.2-p0 > CMD = ~/.multiruby/install/1.9.2-p0/bin/ruby -e 'class String; def ord; self[0]; end unless "".respond_to? :ord; end; p "c".ord' > > 99 > > RESULT = 0 > > TOTAL RESULT = 0 failures out of 4 > > Passed: 1.9.2-p0, 1.9.1-p129, 1.8.6-p399, 1.8.7-p302 > Failed: > 505 % >