From: Elliott Cable Date: 2009-08-01T04:54:58+09:00 Subject: Re: Byte–stream parsing in Ruby Thanks to everybody involved here, I now have a great solution that works really well. I also ended up using EventMachine to get the individual bytes from the keyboard, it’s a lot more efficient. Here’s my final solution, incase anybody’s interested: require 'eventmachine' module Handler def initialize @buffer = "" end def receive_data byte byte.force_encoding Encoding.find('locale') @buffer << byte check_buffer end private def check_buffer if @buffer.valid_encoding? p @buffer @buffer = "" end end end EM.run{ EM.open_keyboard Handler } -- Posted via http://www.ruby-forum.com/.