Project

General

Profile

Actions

Bug #16422

closed

IO#set_encoding_by_bom when encoding is already set

Added by zverok (Victor Shepelev) about 5 years ago. Updated about 5 years ago.

Status:
Closed
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?..

Actions #1

Updated by nobu (Nobuyoshi Nakada) about 5 years 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]

Actions

Also available in: Atom PDF

Like0
Like0