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-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.5 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.4 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.2 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-5.0.1 vendor/bundle/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/unf-0.1.4/lib/unf/normalizer_jruby.rb