From: Brian Candler Date: 2011-03-20T22:19:43+09:00 Subject: Re: A question about Ruby 1.9's "external encoding" Robert K. wrote in post #988404: > --------------------------------------------------- IO#external_encoding > io.external_encoding => encoding > > From Ruby 1.9.1 > ------------------------------------------------------------------------ > Returns the Encoding object that represents the encoding of the > file. If io is write mode and no encoding is specified, returns > +nil+. > > I'd say it means that the default encoding is used. No, it doesn't. > Apparently the file *is* encoded in UTF-8 because I can read it without > errors ruby 1.9 does not give errors if you read a file which is not UTF-8 encoded with the external encoding is UTF-8. You will just get strings with valid_encoding? false. It will give errors if you attempt UTF-8 regexp matches on the data though. The rules for which methods give errors and which don't are pretty odd. For example, string[n] doesn't give an exception, even if the string is invalid. -- Posted via http://www.ruby-forum.com/.