Module: UTF8Proc::JRuby::ClassMethods

Defined in:
lib/utf8_proc/jruby.rb

Overview

Methods added to the UTF8Proc module in JRuby (instead of the C ones)

Instance Method Summary collapse

Instance Method Details

#NFC(string) ⇒ Object

See Also:



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

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

#NFD(string) ⇒ Object

See Also:



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

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

#NFKC(string) ⇒ Object

See Also:



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

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

#NFKC_CF(string) ⇒ Object

See Also:



47
48
49
# File 'lib/utf8_proc/jruby.rb', line 47

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

#NFKD(string) ⇒ Object

See Also:



42
43
44
# File 'lib/utf8_proc/jruby.rb', line 42

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

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

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/utf8_proc/jruby.rb', line 52

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