Actions
Bug #16422
closedIO#set_encoding_by_bom when encoding is already set
Description
IO#set_encoding_by_bom
docs say:
If ios is not binmode or its encoding has been set already, an exception will be raised.
In reality this does not happen (or I don't understand the meaning of bold statement above):
File.write("tmp/bom.txt", "\u{FEFF}мама")
ios = File.open("tmp/bom.txt", "rb", encoding: 'Windows-1251')
ios.external_encoding
# => #<Encoding:Windows-1251>
ios.set_encoding_by_bom
# => #<Encoding:UTF-8>
ios.external_encoding
# => #<Encoding:UTF-8>
...though in code, seems that error should be raised.
I wonder if it is an error in docs, bug in code, or just my misunderstanding?..
Actions
Like0
Like0