Sha256: 0d0a86adf8b31ce382b94cf8e4a27ff537ac1d05968cb3daf8c170bc2eceb41d

Contents?: true

Size: 1.29 KB

Versions: 275

Compression:

Stored size: 1.29 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

module Nokogiri
  class EncodingHandler
    # Popular encoding aliases not known by all iconv implementations that Nokogiri should support.
    USEFUL_ALIASES = {
      # alias_name => true_name
      "NOKOGIRI-SENTINEL" => "UTF-8", # indicating the Nokogiri has installed aliases
      "Windows-31J" => "CP932", # Windows-31J is the IANA registered name of CP932.
      "UTF-8" => "UTF-8", # for JRuby tests, this is a no-op in CRuby
    }

    class << self
      def install_default_aliases
        USEFUL_ALIASES.each do |alias_name, name|
          EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil?
        end
      end
    end

    # :stopdoc:
    if Nokogiri.jruby?
      class << self
        def [](name)
          storage.key?(name) ? new(storage[name]) : nil
        end

        def alias(name, alias_name)
          storage[alias_name] = name
        end

        def delete(name)
          storage.delete(name)
        end

        def clear_aliases!
          storage.clear
        end

        private

        def storage
          @storage ||= {}
        end
      end

      def initialize(name)
        @name = name
      end

      attr_reader :name
    end
  end
end

Nokogiri::EncodingHandler.install_default_aliases

Version data entries

275 entries across 275 versions & 9 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/nokogiri-1.16.6-x86_64-linux/lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x86-mingw32 lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x86-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x86_64-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x86_64-darwin lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x64-mingw-ucrt lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-x64-mingw32 lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-java lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7 lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-arm-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-arm64-darwin lib/nokogiri/encoding_handler.rb
nokogiri-1.15.7-aarch64-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x86-mingw32 lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x86-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x86_64-linux lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x86_64-darwin lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x64-mingw-ucrt lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-x64-mingw32 lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8-java lib/nokogiri/encoding_handler.rb
nokogiri-1.16.8 lib/nokogiri/encoding_handler.rb