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


The patch doesn't work on following case:

%  ./ruby -e'IO.write"p","a";open("p","r:BOM|utf-8:utf-8"){|f|p f.read.size}'
-e:1:in `read': code converter not found (UTF-8 to UTF-8) (Encoding::ConverterNotFoundError)
        from -e:1:in `block in <main>'
        from -e:1:in `open'
        from -e:1:in `<main>'
----------------------------------------
Bug #8323: no conversion by "bom|utf-8"
https://bugs.ruby-lang.org/issues/8323#change-38887

Author: nobu (Nobuyoshi Nakada)
Status: Open
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: M17N
Target version: current: 2.1.0
ruby -v: 2.1.0
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


Mode spec in open and etc. accepts BOM-prefix UTF encoding, however if the external and internal encodings given there are same no conversion take place regardless the actual external encoding.
Since the encoding prefixed with "BOM" is not a real encoding, but just a fallback, the conversion should honor the detected encoding by BOM.



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