Project

General

Profile

Bug #16422

IO#set_encoding_by_bom when encoding is already set

Added by zverok (Victor Shepelev) about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:96239]

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?..

Associated revisions

Revision e8c62836
Added by nobu (Nobuyoshi Nakada) about 1 month ago

IO#set_encoding_by_bom should err when encoding is already set

Except for ASCII-8BIT. [Bug #16422]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|e8c62836a6292bf2f691de458b24ea50c51b452a.


IO#set_encoding_by_bom should err when encoding is already set

Except for ASCII-8BIT. [Bug #16422]

Also available in: Atom PDF