Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Child: force all IO objects and buffers to BINARY for now
Otherwise, the out and err buffer strings are assumed to be whatever the source file encoding is (US-ASCII currently), while the IO objects will get their encoding from Encoding.default_external and Encoding.default_internal which can vary by environment (LANG, LC_ALL, etc.). This causes the out and err strings to be implicitly converted to a different encoding when appending to them with String#<< data we've read off the IO object. Forcing everything to binary also lets us get rid of the need to define String#bytesize since #size = #bytesize with BINARY encoding. At some point we'll need to deal with this stuff in a way that's consistent with Ruby's core IO methods. We should accept input in any encoding and transcode it to the Encoding default or a user-specified external_encoding when writing to the stdin fd. We should also read data off of the stdout/stderr IO objects in the default or user-specified external_encoding and transcode to the internal_encoding. Unfortunately, that's going to require also adding support for specifying encodings to Child::new so that you can override Encoding.default_internal/default_external for binary reads and whatnot.
- Loading branch information