class Temple::Filters::RemoveBOM

Remove BOM from input string

@api public

Public Instance Methods

call(s) click to toggle source
# File lib/temple/filters/remove_bom.rb, line 7
def call(s)
  if s.respond_to?(:encoding)
    if s.encoding.name =~ /^UTF-(8|16|32)(BE|LE)?/
      s.gsub(Regexp.new("\\A\uFEFF".encode(s.encoding.name)), '')
    else
      s
    end
  else
    s.gsub(/\A\xEF\xBB\xBF/, '')
  end
end