From: Tanaka Akira Date: 2009-02-23T01:00:41+09:00 Subject: [ruby-core:22332] Re: [Feature #908] Should be an easy way of reading N characters from am I/O stream In article <6.0.0.20.2.20090220134502.0823ee98@localhost>, Martin Duerst writes: > Very much so. A typical example would be Georgia, where > many names are as long as some of the longer ones in > Europe, but they require 3 bytes per character. I see. The name of the President of Georgia needs 30 characters and 84 bytes. http://en.wikipedia.org/wiki/Mikheil_Saakashvili > Can you give more specific explanations of why reading a number > of characters might not be secure? I considered ISO-2022-JP, Unicode combining characters and Punycode. In these encodings, fixed number of characters doesn't limit the number of bytes. However they may not cause problem now because Ruby doesn't support combining characters, etc. But Ruby's encoding system is extensible. It is possible to define an encoding which makes the character-wise limit insecure. -- Tanaka Akira