From: Yukihiro Matsumoto Date: 2008-09-17T11:55:42+09:00 Subject: [ruby-core:18644] Re: Reading non-ascii compatible files Hi, In message "Re: [ruby-core:18637] Reading non-ascii compatible files" on Wed, 17 Sep 2008 08:27:25 +0900, "Michael Selig" writes: |The weird thing is that I can open it for writing without "b". Really? It checks for me: ruby -v -I .ext/i686-linux -E UTF-16LE -e "File.open('/tmp/xx', mode: 'w')" ruby 1.9.0 (2008-09-16 revision 19380) [i686-linux] -e:1:in `initialize': ASCII incompatible encoding needs binmode (ArgumentError) from -e:1:in `open' from -e:1:in `
' But File.open(path, "w") does not check. This is a bug. |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? You can specify mode by keyword argument: ruby -v -E UTF-16BE -e "IO.readlines('/tmp/xx', mode: "rb")" matz.