Module: UTF8Proc::JRuby::ClassMethods

Defined in:
lib/utf8_proc/jruby.rb

Instance Method Summary collapse

Instance Method Details

#NFC(string) ⇒ Object



20
21
22
# File 'lib/utf8_proc/jruby.rb', line 20

def NFC(string)
  JTNORM.normalize(string, JTNORM::Form::NFC)
end

#NFD(string) ⇒ Object



24
25
26
# File 'lib/utf8_proc/jruby.rb', line 24

def NFD(string)
  JTNORM.normalize(string, JTNORM::Form::NFD)
end

#NFKC(string) ⇒ Object



28
29
30
# File 'lib/utf8_proc/jruby.rb', line 28

def NFKC(string)
  JTNORM.normalize(string, JTNORM::Form::NFKC)
end

#NFKC_CF(string) ⇒ Object



36
37
38
# File 'lib/utf8_proc/jruby.rb', line 36

def NFKC_CF(string)
  NFKC(string).to_java(:string).toLowerCase
end

#NFKD(string) ⇒ Object



32
33
34
# File 'lib/utf8_proc/jruby.rb', line 32

def NFKD(string)
  JTNORM.normalize(string, JTNORM::Form::NFKD)
end

#normalize(string, form = :nfc) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/utf8_proc/jruby.rb', line 40

def normalize(string, form = :nfc)
  case form
  when :nfc
    NFC(string)
  when :nfd
    NFD(string)
  when :nfkc
    NFKC(string)
  when :nfkd
    NFKD(string)
  when :nfkc_cf
    NFKC_CF(string)
  else
    raise ArgumentError, "Second argument must be one of [:nfc (default)," \
                         " :nfd, :nfkc, :nfkd, :nfkc_cf]"
  end
end