[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:54682] [ruby-trunk - Bug #8342][Rejected] IO.readlines ignores Encoding.default_internal
From:       "naruse (Yui NARUSE)" <naruse () airemix ! jp>
Date:       2013-04-29 5:00:05
Message-ID: redmine.journal-39028.20130429140004 () ruby-lang ! org
[Download RAW message or body]


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

Status changed from Assigned to Rejected

If external encoding is ASCII-8BIT, the input content is considered as binary.
It is out of text encoding conversion and its encoding kept as ASCII-8BIT even if \
                default_internal is set.
----------------------------------------
Bug #8342: IO.readlines ignores Encoding.default_internal if \
Encoding.default_external is ASCII-8BIT \
https://bugs.ruby-lang.org/issues/8342#change-39028

Author: leocassarani (Leo Cassarani)
Status: Rejected
Priority: Normal
Assignee: naruse (Yui NARUSE)
Category: M17N
Target version: current: 2.1.0
ruby -v: 1.9.3
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


Under normal circumstances, IO.readlines will transcode from \
Encoding.default_external to Encoding.default_internal:

File.open('hi', 'w') { |f| f.puts "hello\n" }
Encoding.default_external = Encoding::US_ASCII
Encoding.default_internal = Encoding::UTF_8
puts IO.readlines('hi').first.encoding
#=> UTF-8

However, when Encoding.default_external is set to ASCII-8BIT, IO.readlines will \
always use ASCII-8BIT, regardless of what Encoding.default_internal is set to:

File.open('hi', 'w') { |f| f.puts "hello\n" }
Encoding.default_external = Encoding::ASCII_8BIT
Encoding.default_internal = Encoding::UTF_8
puts IO.readlines('hi').first.encoding
#=> ASCII-8BIT

Using IO#gets instead of IO.readlines will produce the same behaviour.


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic