Issue #8255 has been updated by naruse (Yui NARUSE).


This is because
* UTF-16 is dummy encoding; you must use UTF-16BE, UTF-16LE, or BOM|UTF-* specifier; OR some other treatment is needed on Ruby.
* default line separator is ASCII \n, not UTF-16 \n. you must explicitly specify UTF-16(BE|LE) \n, or convert to some internal encoding; OR some other special treatment is needed on Ruby

----------------------------------------
Bug #8255: File#each_line omits last byte (==\0) if encoding is utf-16
https://bugs.ruby-lang.org/issues/8255#change-38451

Author: arton (Akio Tajima)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: current: 2.1.0
ruby -v:  ruby 2.1.0dev (2013-04-11) [i386-mswin32_100]


If File#each_line was given utf-16 encoded file with 'rb:utf-16', each line lacks the last one byte.
For example if the line is "a\0\r\0\n\0" in binary, the read line contains "a\0\r\0\r".

See the attchement.
This issue is appear both current 2.1.0 and 2.0.0.


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