Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: Encoding
-
Labels:None
-
Environment:OSX
-
Number of attachments :
Description
Reading a UTF-16LE file does not return the correct characters:
Jeffs-MacBook-Pro:~ jeffwilliams$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
Jeffs-MacBook-Pro:~ jeffwilliams$ ruby write-utf16le.rb
Jeffs-MacBook-Pro:~ jeffwilliams$ od -t x1 test1
0000000 55 00 54 00 46 00 2d 00 31 00 36 00 4c 00 45 00
0000020 0a 00
0000022
Jeffs-MacBook-Pro:~ jeffwilliams$ ruby read-utf16le.rb
U
T
F
-
1
6
L
E
Jeffs-MacBook-Pro:~ jeffwilliams$ ruby -v
jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-19 00c8c98) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_05) [darwin-x86_64-java]
Jeffs-MacBook-Pro:~ jeffwilliams$ ruby read-utf16le.rb
U
T
F
-
1
6
L
E
Jeffs-MacBook-Pro:~ jeffwilliams$
Where the relevant files are:
write-utf16le.rb:
File.open("test1", "wb:UTF-16LE") do |f|
f.puts "UTF-16LE"
end
read-utf16le.rb:
File.open("test1", "rb:UTF-16LE") do |f|
f.each_char do |char|
puts char
end
end
Issue Links
- is depended upon by
-
JRUBY-6694
Invalid byte sequence in utf-8
-
Confirmed on master. Also, the write side of this does not seem to properly write UTF-16 to the file. I had to use MRI.