module Sprockets::EncodingUtils

def detect_unicode(str)

Returns encoded String.

str - ASCII-8BIT encoded String

Attempts to parse Unicode BOM and falls back to UTF-8.

Public: Detect Unicode string.
def detect_unicode(str)
  str = detect_unicode_bom(str)
  # Fallback to UTF-8
  if str.encoding == Encoding::BINARY
    str.force_encoding(Encoding::UTF_8)
  end
  str
end