module Sprockets::EncodingUtils

def detect(str)

Returns encoded String.

str - ASCII-8BIT encoded String

environment's external encoding.
Attempts to parse any Unicode BOM otherwise falls back to the

Public: Basic string detecter.
def detect(str)
  str = detect_unicode_bom(str)
  # Attempt Charlock detection
  if str.encoding == Encoding::BINARY
    charlock_detect(str)
  end
  # Fallback to environment's external encoding
  if str.encoding == Encoding::BINARY
    str.force_encoding(Encoding.default_external)
  end
  str
end