Module: Decidim::IoEncoder

Defined in:
decidim-core/lib/decidim/io_encoder.rb

Overview

This module encloses all methods to uniformize encodings from incoming and outgoing data streams.

Decidim takes UTF-8 as its official, internal encoding.

Incoming All data arriving from external sources with unknown encodings will be transformed to UTF-8.

Class Method Summary collapse

Class Method Details

.to_standard_encoding(inn) ⇒ Object



16
17
18
19
20
21
# File 'decidim-core/lib/decidim/io_encoder.rb', line 16

def self.to_standard_encoding(inn)
  detection = CharlockHolmes::EncodingDetector.detect(inn)

  inn = CharlockHolmes::Converter.convert(inn, detection[:encoding], "UTF-8") if detection[:type] == :text
  inn
end