ruby 1.9: handling meta and control keys

  • Thread starter (rkumar) Sentinel
  • Start date
R

(rkumar) Sentinel

1.8 used to return an int for say ?\M-a or ?C-a (when user types meta-a
or control-a).

1.9 returns a string as "\xE1" instead of 225.

The only way i have been able to convert "\xE1" to 225 is removing the
first 2 chars and then using to_i(16).

"E1".to_i(16)

If i do:

"\xE1".to_i(16) i get a zero.

Is there a clean way of handling meta and control chars in 1.9. Or at
least a clean way of converting them to integers. I need them as
integers since I am porting a 1.8 app that uses them as integers.

Also, is there anyone using the return values of ?\M-a etc as is,
without conversion. I would like to hear how.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top