Method: Sprockets::EncodingUtils#charlock_detect

Defined in:
lib/sprockets/encoding_utils.rb

#charlock_detect(str) ⇒ Object

Internal: Use Charlock Holmes to detect encoding.

To enable this code path, require ‘charlock_holmes’

Returns encoded String.



121
122
123
124
125
126
127
128
129
# File 'lib/sprockets/encoding_utils.rb', line 121

def charlock_detect(str)
  if defined? CharlockHolmes::EncodingDetector
    if detected = CharlockHolmes::EncodingDetector.detect(str)
      str.force_encoding(detected[:encoding]) if detected[:encoding]
    end
  end

  str
end