Method: Sprockets::EncodingUtils#detect_unicode
- Defined in:
- lib/sprockets/encoding_utils.rb
#detect_unicode(str) ⇒ Object
Public: Detect Unicode string.
Attempts to parse Unicode BOM and falls back to UTF-8.
str - ASCII-8BIT encoded String
Returns encoded String.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sprockets/encoding_utils.rb', line 138 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 |