module Haml::Util

def parse_haml_magic_comment(str)

Returns:
  • ((Boolean, String or nil)) -
def parse_haml_magic_comment(str)
  scanner = StringScanner.new(str.dup.force_encoding(Encoding::ASCII_8BIT))
  bom = scanner.scan(/\xEF\xBB\xBF/n)
  return bom unless scanner.scan(/-\s*#\s*/n)
  if (coding = try_parse_haml_emacs_magic_comment(scanner))
    return bom, coding
  end
  return bom unless scanner.scan(/.*?coding[=:]\s*([\w-]+)/in)
  return bom, scanner[1]
end