Sha256: cc0e8ba6d7d499e014ff642ead59c640cb365143998f4b9112eb105a0c508217

Contents?: true

Size: 608 Bytes

Versions: 118

Compression:

Stored size: 608 Bytes

Contents

require 'java'

module UNF # :nodoc: all
  class Normalizer
    def initialize()
      @normalizer = java.text.Normalizer
    end

    def normalize(string, normalization_form)
      @normalizer.normalize(string, form(normalization_form))
    end

    private

    def form(symbol)
      case symbol
      when :nfc
        @normalizer::Form::NFC
      when :nfd
        @normalizer::Form::NFD
      when :nfkc
        @normalizer::Form::NFKC
      when :nfkd
        @normalizer::Form::NFKD
      else
        raise ArgumentError, "unknown normalization form: #{symbol.inspect}"
      end
    end
  end
end

Version data entries

118 entries across 90 versions & 14 rubygems

Version Path
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/unf-0.1.4-java/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.8 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.7 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.6 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb