Skip to content

Commit 3ad9b17

Browse files
committed
- Updated File.read_utf to assume String encoding support. (wtn)
[git-p4: depot-paths = "//src/hoe/dev/": change = 14711]
1 parent c3f4f51 commit 3ad9b17

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

lib/hoe.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -953,15 +953,8 @@ def maybe_load_yaml path # :nodoc:
953953
class File # :nodoc:
954954
# Like File::read, but strips out a BOM marker if it exists.
955955
def self.read_utf path
956-
r19 = "<3".respond_to? :encoding
957-
opt = r19 ? "r:bom|utf-8" : "rb"
958-
959-
open path, opt do |f|
960-
if r19 then
961-
f.read
962-
else
963-
f.read.sub %r%\A\xEF\xBB\xBF%, ""
964-
end
956+
open path, "r:bom|utf-8" do |f|
957+
f.read
965958
end
966959
end
967960
end

test/test_hoe.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ def test_file_read_utf
192192

193193
content = File.read_utf io.path
194194
assert_equal "BOM", content
195-
196-
if content.respond_to? :encoding then
197-
assert_equal Encoding::UTF_8, content.encoding
198-
end
195+
assert_equal Encoding::UTF_8, content.encoding
199196
end
200197
end
201198

0 commit comments

Comments
 (0)