Issue #10815 has been updated by Nobuyoshi Nakada.

Status changed from Open to Rejected

Encoding is a keyword argument.

~~~
Dir.foreach( dirname, encoding: enc ) {| filename | block }  -> nil
~~~

>     Dir.foreach(Dir.pwd, true, false, nil) # => no error

It returns an enumerator.

~~~
Dir.foreach( dirname )                                       -> an_enumerator
~~~

You'll see an ArgumentError when enumerating it.


----------------------------------------
Bug #10815: Dir.foreach in block form does not allow encoding
https://bugs.ruby-lang.org/issues/10815#change-51330

* Author: Daniel Berger
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [i386-mswin32_120]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
It doesn't appear that Dir.foreach{} allows an encoding:

    enc = Encoding::UTF_16LE

    # Without a block, works ok
    p Dir.foreach(Dir.pwd)      # => Enumerator
    p Dir.foreach(Dir.pwd, enc) # => Enumerator

    # With a block, fails if more than 1 argument is passed
    p Dir.foreach(Dir.pwd){ }      # => nil
    p Dir.foreach(Dir.pwd, enc){ } # => ArgumentError



-- 
https://bugs.ruby-lang.org/