From: Michael Selig Date: 2008-09-17T08:27:25+09:00 Subject: [ruby-core:18637] Reading non-ascii compatible files Hi, I have noticed this under Linux: ruby -v -E UTF-16BE -e "open('/tmp/xx')" ruby 1.9.0 (2008-09-16 revision 19371) [i686-linux] -e:1:in `initialize': ASCII incompatible encoding needs binmode (ArgumentError) from -e:1:in `open' from -e:1:in `
' So it seems the only way I can open a UTF-16 file for reading is with the "b" flag, which I thought was only for Windows. The weird thing is that I can open it for writing without "b". Worse is that some methods which don't take a "mode" parameter don't work at all: ruby -v -E UTF-16BE -e "IO.readlines('/tmp/xx')" ruby 1.9.0 (2008-09-16 revision 19371) [i686-linux] -e:1:in `readlines': ASCII incompatible encoding needs binmode (ArgumentError) from -e:1:in `
' Why is this? Bug? Even under Windows this doesn't make much sense to me! Cheers Mike