From: Run Paint Run Run Date: 2010-09-02T15:32:36+09:00 Subject: [ruby-core:32007] Re: not use system for default encoding > $ cat test.rb > p File.read('other_file_unknown_encoding').encoding > p 'abc'.encoding > > $ ruby test.rb > # > # > > for better or worse, even though 'other_file_unknown_encoding' has > only ASCII characters, its encoding is set to my system default. ��This > means that if I package up the file "other_file_unknown_encoding" in > my gem, and read it later, I *must* specify its encoding when I read > it. ��So it will succeed locally and *fail* on another box, which to me > adds extra confusion. No. You can show this is not the case yourself by specifying a different default external encoding, then reading in a file. If the file is ASCII-only, it can be read under any ASCII-compatible external encoding without you having to specify a thing. Your file is valid, and identical, in any of these encodings, so the precise one chosen is immaterial. run@paint:/tmp ��� echo "aheh&^^Gah*" >ascii run@paint:/tmp ��� irb >> File.read('ascii').hash => -971653016 >> File.read('ascii', encoding: 'ibm437').hash => -971653016 >> File.read('ascii', encoding: 'utf-8').hash => -971653016 >> File.read('ascii', encoding: 'big5').hash => -971653016 >> Encoding.default_external='shift_jis' => "shift_jis" >> File.read('ascii').encoding => # >> File.read('ascii').hash => -971653016 > The other surprising thing to me is that it assigns IBM437 not only to > terminal input but also to file input. ��*Nobody* edits files in > IBM437. ��It feels inappropriate to use that for the encoding, or, > really, to have a default for file encoding. I know little of Windows matters, but surely if that���s your system locale, it is indeed the default encoding for editing files. Certainly, your text editor has presumably been configured to use something more sensible, but if not wouldn���t it fallback to IBM437?