From: Izidor Jerebic Date: 2006-06-26T15:58:30+09:00 Subject: Re: Unicode roadmap? On 26.6.2006, at 8:08, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Unicode roadmap?" > on Mon, 26 Jun 2006 13:51:33 +0900, Izidor Jerebic > writes: > | > |Above code assumes all file operations return byte arrays. What is > |the code when we want to obtain String of characters? > > line = File.open(filename, "r", "utf8") {|f| f.gets } > > |What if there is some $KCODE (or equivalent) setting somewhere in the > |program before these lines? What would be the effect of that? > > I think IO#read shall always return "binary" string, since its > specified length should always be in bytes. Anyway, when in doubt, > you can explicitly specify "binary" encoding, Oh, I see. So basically IO always returns ByteArray, and one needs to convert it to String of characters explicitly (or implicitly by specifying a parameter to IO). No magic tagging with encoding. Well, this is nice and easy to understand. But how will this influence the simplicity of small programs in Ruby which deal with data in known (single) encoding? I was under impression that there would be some magic global setting which will enable such programs to use Strings in correct encoding. Thank you for clarifications. They are most welcome... izidor