class File

Public Class Methods

read_utf(path) click to toggle source

Like File::read, but strips out a BOM marker if it exists.

# File lib/hoe.rb, line 926
def self.read_utf path
  r19 = "<3".respond_to? :encoding
  opt = r19 ? "r:bom|utf-8" : "rb"

  open path, opt do |f|
    if r19 then
      f.read
    else
      f.read.sub %r%\A\xEF\xBB\xBF%, ""
    end
  end
end