File: normalizer.rb

package info (click to toggle)
ruby-unf 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 108 kB
  • sloc: ruby: 107; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 800 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'singleton'
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
  require 'unf/normalizer_jruby'
else
  require 'unf/normalizer_cruby'
end

# UTF-8 string normalizer class.  Implementations may vary depending
# on the platform.
class UNF::Normalizer
  include Singleton

  class << self
    # :singleton-method: instance
    #
    # Returns a singleton normalizer instance.

    # :singleton-method: new
    #
    # Returns a new normalizer instance.  Use +singleton+ instead.
    public :new

    # A shortcut for instance.normalize(string, form).
    def normalize(string, form)
      instance.normalize(string, form)
    end
  end

  # :method: normalize
  # :call-seq:
  #   normalize(string, form)
  #
  # Normalizes a UTF-8 string into a given form (:nfc, :nfd, :nfkc or
  # :nfkd).
end