Hi Martin, On Fri, 20 Feb 2009 15:50:50 +1100, Martin Duerst <duerst / it.aoyama.ac.jp> wrote: > In general, I agree that being able to work with character numbers > is desirable. The implementation isn't exactly easy, but I hope > eventually we will get there. My current guess is that this might > mean that we have to move IO and related stuff a bit more towards > a model with classes stacked on top of each other. But that's just > a guess. Sure, that would be sensible. But in 1.9 we are stuck with some methods in class IO which deal with bytes, and some which deal with characters. What I am suggesting (making the "limit" field of IO#gets mean "characters" rather than "bytes rounded to a whole character") is to: 1. Provide something useful (certainly useful to me, and it appears to others) in the 1.9 release of Ruby, and 2. Making an existing method usage more sensible, at a time when it can be still backward compatible with previous Ruby releases. My feeling is that the current usage of "limit" (when applied to multibyte characters) is not at all intuitive, since "gets" deals with characters, not bytes. I doubt whether "bytes rounded to a whole character" is particularly useful at all. If IO#gets is used mainstream with the "limit" parameter as it is, then it will be harder to change in the future, and some other way of achieving the outcome would probably be necessary to maintain backward compatibility. Regarding implementation, I don't think it would be hard, as there is already code in Ruby to copy N characters. > But regarding your point of format screwup, measuring things in > characters won't help. Assuming that each character has the same > width just doesn't carry very far if you look at all the scripts > around the world. In general, you are right. And even most ASCII fonts these days are variable width. But I was asked for a specific example of why being able to read a fixed number of characters from an I/O stream was a good idea. In this particular case we sometimes use fixed width printer fonts, and these rely on the right number of characters to be printed to give vertical alignment. Cheers Mike