Sha256: 795cd53552db2ee3df3a38e8081dd3723d0342f78e37fea2e7bf04c49db17b9d

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

case
when defined?(UNF::Normalizer)
  # Probably unf_ext is preloaded.
when String.method_defined?(:unicode_normalize)
  class String
    [:nfc, :nfd, :nfkc, :nfkd].each { |form|
      eval %{
        remove_method :to_#{form} if method_defined?(:to_#{form})

        def to_#{form}
          unicode_normalize(#{form.inspect})
        end
      }
    }
  end

  module UNF # :nodoc: all
    class Normalizer
      def normalize(string, normalization_form)
        String.try_convert(string).unicode_normalize(normalization_form)
      end
    end
  end
else
  require 'unf_ext'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unf-0.2.0-java lib/unf/normalizer_cruby.rb
unf-0.2.0 lib/unf/normalizer_cruby.rb