Module: UTF8Proc

Includes:
JRuby
Defined in:
lib/utf8_proc.rb,
lib/utf8_proc/jruby.rb,
lib/utf8_proc/version.rb,
ext/utf8_proc/utf8_proc.c

Defined Under Namespace

Modules: JRuby

Constant Summary collapse

VERSION =
"0.3.0".freeze
LIBRARY_VERSION =
rb_str_freeze(
  rb_enc_str_new(libVersion, strlen(libVersion), enc_utf8)
)

Class Method Summary collapse

Methods included from JRuby

included

Class Method Details

.NFC(string) ⇒ Object



36
37
38
# File 'ext/utf8_proc/utf8_proc.c', line 36

VALUE toNFC(VALUE self, VALUE string) {
  return normInternal(string, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
}

.NFD(string) ⇒ Object



40
41
42
# File 'ext/utf8_proc/utf8_proc.c', line 40

VALUE toNFD(VALUE self, VALUE string) {
  return normInternal(string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE);
}

.NFKC(string) ⇒ Object



44
45
46
# File 'ext/utf8_proc/utf8_proc.c', line 44

VALUE toNFKC(VALUE self, VALUE string) {
  return normInternal(string,UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
}

.NFKC_CF(string) ⇒ Object



52
53
54
# File 'ext/utf8_proc/utf8_proc.c', line 52

VALUE toNFKC_CF(VALUE self, VALUE string) {
  return normInternal(string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT | UTF8PROC_CASEFOLD);
}

.NFKD(string) ⇒ Object



48
49
50
# File 'ext/utf8_proc/utf8_proc.c', line 48

VALUE toNFKD(VALUE self, VALUE string) {
  return normInternal(string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
}

.normalize(*args) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'ext/utf8_proc/utf8_proc.c', line 57

VALUE norm(int argc, VALUE* argv, VALUE self){
  VALUE string;
  VALUE form;
  rb_scan_args(argc, argv, "11", &string, &form);

  if (NIL_P(form)) {
    return toNFC(self, string);
  }

  ID s_form;
  s_form = SYM2ID(form);
  if (s_form == NFC) {
    return toNFC(self, string);
  }else if(s_form == NFD) {
    return toNFD(self, string);
  }else if(s_form == NFKC) {
    return toNFKC(self, string);
  }else if(s_form == NFKD) {
    return toNFKD(self, string);
  }else if(s_form == NFKC_CF) {
    return toNFKC_CF(self, string);
  }else{
    rb_raise(rb_eArgError, "%s",
             "Second argument must be one of [:nfc (default), :nfd, :nfkc, " \
             ":nfkd, :nfkc_cf]");
  }
}