-
-
Notifications
You must be signed in to change notification settings - Fork 942
Open
Description
The OutputStream implementation returned by RubyIO.getOutputStream always treats incoming bytes as being ASCII-8BIT encoding. This breaks writes when the underlying RubyIO has been initialized with an incompatible external encoding, like UTF-8.
jruby/core/src/main/java/org/jruby/RubyIO.java
Lines 347 to 355 in b79d640
| @Override | |
| public void write(byte[] b) throws IOException { | |
| RubyIO.this.write(runtime.getCurrentContext(), RubyString.newStringNoCopy(runtime, b)); | |
| } | |
| @Override | |
| public void write(byte[] b, int off, int len) throws IOException { | |
| RubyIO.this.write(runtime.getCurrentContext(), RubyString.newStringNoCopy(runtime, b, off, len)); | |
| } |
This led to one failure in the Psych tests as noted in ruby/psych#481 and fixed by #6587.
I believe this stream should handle the encoding better using one of these options (perhaps?):
- Assume the bytes are encoded like the IO's internal encoding, which may be the default UTF-8 of Ruby. The bytes will be transcoded to whatever the external encoding is supposed to be.
- Assume the bytes are encoded like the IO's external encoding. They will be written directly without any transcoding (or any verification that they are in that encoding).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels