Sha256: 48d14f7bf6389f54e6d2294d94c572348e83f807fdc99fd5d10c71e436ef8843

Contents?: true

Size: 628 Bytes

Versions: 70

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

require "charlock_holmes"

module Decidim
  # 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.
  #
  module IoEncoder
    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
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
decidim-core-0.26.8 lib/decidim/io_encoder.rb
decidim-core-0.27.4 lib/decidim/io_encoder.rb
decidim-core-0.27.3 lib/decidim/io_encoder.rb
decidim-core-0.26.7 lib/decidim/io_encoder.rb
decidim-core-0.26.5 lib/decidim/io_encoder.rb
decidim-core-0.27.2 lib/decidim/io_encoder.rb
decidim-core-0.27.1 lib/decidim/io_encoder.rb
decidim-core-0.26.4 lib/decidim/io_encoder.rb
decidim-core-0.27.0 lib/decidim/io_encoder.rb
decidim-core-0.26.3 lib/decidim/io_encoder.rb
decidim-core-0.27.0.rc2 lib/decidim/io_encoder.rb
decidim-core-0.27.0.rc1 lib/decidim/io_encoder.rb
decidim-core-0.26.2 lib/decidim/io_encoder.rb
decidim-core-0.26.1 lib/decidim/io_encoder.rb
decidim-core-0.26.0 lib/decidim/io_encoder.rb
decidim-core-0.26.0.rc2 lib/decidim/io_encoder.rb
decidim-core-0.26.0.rc1 lib/decidim/io_encoder.rb
decidim-core-0.25.2 lib/decidim/io_encoder.rb
decidim-core-0.25.1 lib/decidim/io_encoder.rb
decidim-core-0.25.0 lib/decidim/io_encoder.rb