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.29.1 lib/decidim/io_encoder.rb
decidim-core-0.28.4 lib/decidim/io_encoder.rb
decidim-core-0.27.9 lib/decidim/io_encoder.rb
decidim-core-0.29.0 lib/decidim/io_encoder.rb
decidim-core-0.28.3 lib/decidim/io_encoder.rb
decidim-core-0.27.8 lib/decidim/io_encoder.rb
decidim-core-0.29.0.rc4 lib/decidim/io_encoder.rb
decidim-core-0.29.0.rc3 lib/decidim/io_encoder.rb
decidim-core-0.29.0.rc2 lib/decidim/io_encoder.rb
decidim-core-0.29.0.rc1 lib/decidim/io_encoder.rb
decidim-core-0.28.2 lib/decidim/io_encoder.rb
decidim-core-0.27.7 lib/decidim/io_encoder.rb
decidim-core-0.28.1 lib/decidim/io_encoder.rb
decidim-core-0.27.6 lib/decidim/io_encoder.rb
decidim-core-0.26.10 lib/decidim/io_encoder.rb
decidim-core-0.26.9 lib/decidim/io_encoder.rb
decidim-core-0.28.0 lib/decidim/io_encoder.rb
decidim-core-0.27.5 lib/decidim/io_encoder.rb
decidim-core-0.28.0.rc5 lib/decidim/io_encoder.rb
decidim-core-0.28.0.rc4 lib/decidim/io_encoder.rb