From: danielcavanagh@... Date: 2008-12-22T10:36:00+09:00 Subject: [ruby-core:20774] Re: [Feature #908] Should be an easy way of reading N characters from am I/O stream > Feature #908: Should be an easy way of reading N characters from am I/O > stream > http://redmine.ruby-lang.org/issues/show/908 > > Author: Michael Selig > Status: Open, Priority: Normal > > I know of no way of reading N characters (as opposed to bytes) and > returning a string other than writing a loop with getc or each_char. > > Suggestions - one of: > > 1) Change the "limit" paramater on IO#gets to mean characters rather than > bytes. This would change existing behaviour, so may be unacceptable. > > 2) Add an optional "limit" parameter to IO#getc, so IO#getc will read up > to this many characters or perhaps a new method IO#readchars/read_chars that matches IO#read, and then maybe aliasing IO#read to IO#readbytes/read_bytes to keep it consistent