From: "Peña, Botp" Date: 2008-11-27T16:15:15+09:00 Subject: Re: Alternatives to ?\C-n, ?\M-a etc in ruby 1.9 From: Nit Khair [mailto:sentinel.2001@gmx.com] # But what about ?\C-a or ?\M-a (control and meta keys). # Is there a workaround for them? # Sorry, I don't have 1.9, so cant try out "\C-a".ord . am on a win machine, so my ruby1.9 is old ver. sorry. anyway, ctl and meta still work. eg, C:\family\ruby>\ruby1.9\bin\ruby -ve 'p "\C-m"; p "\r"' ruby 1.9.0 (2008-06-20 revision 17482) [i386-mswin32] "\r" "\r" C:\family\ruby>\ruby1.9\bin\ruby -ve 'p "\C-m".ord; p "\r".ord' ruby 1.9.0 (2008-06-20 revision 17482) [i386-mswin32] 13 13 # Also, To be compatible with both 1.8 amd 1.9, would i # use something like: # ch = str.respond_to? :ord ? str[0].ord : str[0] # or # str[0] is_a? Fixnum ? str[0] : str[0].ord why not create your own String#ord func? i think string#ord works for both 1.8.7 and 1.9, so you just have to create one for 1.8.6