Skip to content

Fix File.read with UTF-16LE#2605

Closed
lumeet wants to merge 1 commit intojruby:masterfrom
lumeet:file_bom_16le
Closed

Fix File.read with UTF-16LE#2605
lumeet wants to merge 1 commit intojruby:masterfrom
lumeet:file_bom_16le

Conversation

@lumeet
Copy link
Contributor

@lumeet lumeet commented Feb 17, 2015

File.open("a.txt", "w+") do |f|
  f.write "\xFF\xFE"
  f.close
end
File.read("a.txt", mode: "rb:bom|utf-8")

...results in...

<java.lang.ClassCastException: org.jruby.RubyNil cannot be cast to org.jruby.RubyFixnum>

A check for a null value seems to be missing after the BOM.

The test_truncate_wbuf removal is just general cleanup. It doesn't have anything to do with the fix. I guess it's ok. :)

A null value after the BOM no longer causes an error.
@enebo enebo added this to the JRuby 9.0.0.0.rc1 milestone May 1, 2015
@enebo enebo added the core label May 1, 2015
@enebo
Copy link
Member

enebo commented May 1, 2015

@lumeet Sorry for leaving this so long but it no longer applies cleanly. Can you update this PR?

@lumeet
Copy link
Contributor Author

lumeet commented May 1, 2015

@enebo I'm closing this. The bug is fixed by another commit and test/mri/excludes/TestFile.rb looks the same on master, too.

@lumeet lumeet closed this May 1, 2015
@lumeet lumeet deleted the file_bom_16le branch May 1, 2015 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants