From: Julian 'Julik' Tarkhanov Date: 2006-06-26T21:53:39+09:00 Subject: Re: Unicode roadmap? On 26-jun-2006, at 3:11, Austin Ziegler wrote: > > Okay. What class should I get here? > > data = File.open("file.txt", "rb") { |f| f.read } > > Under the people who want separate ByteVector and String class, I'll > need *two* APIs: > > st = File.open("file.txt", "rb") { |f| f.read_string } > bv = File.open("file.txt", "rb") { |f| f.read_bytes } > > Stupid, stupid, stupid, stupid. If I have guessed wrong about the > contents of file.txt, I have to rewind and read it again. Better to > *always* read as bytes and then say, "this is actually UTF-8". This > would be as stupid in C++, Java, or C#: Not so fast, let's say you read from a file: > st = File.open("file.txt", "rb") { |f| f.read(4056) } and you recieve a PART of a unicode string (because you cannot know where to stop reading before yoy look into the structure). The only way to make what you read valid now is to slide along the byte length and try to catch the bytes that you skipped. Should I continue? -- Julian 'Julik' Tarkhanov please send all personal mail to me at julik.nl