Module: UTF8Proc::StringExtension
- Included in:
- String
- Defined in:
- ext/utf8_proc/utf8_proc.c
Instance Method Summary collapse
- #NFC ⇒ Object
- #NFD ⇒ Object
- #NFKC ⇒ Object
- #NFKC_CF ⇒ Object
- #NFKD ⇒ Object
- #normalize(*args) ⇒ Object
Instance Method Details
#NFC ⇒ Object
74 75 76 |
# File 'ext/utf8_proc/utf8_proc.c', line 74
static VALUE StoNFC(VALUE string) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
}
|
#NFD ⇒ Object
84 85 86 |
# File 'ext/utf8_proc/utf8_proc.c', line 84
static VALUE StoNFD(VALUE string) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE);
}
|
#NFKC ⇒ Object
94 95 96 |
# File 'ext/utf8_proc/utf8_proc.c', line 94
static VALUE StoNFKC(VALUE string) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
}
|
#NFKC_CF ⇒ Object
114 115 116 |
# File 'ext/utf8_proc/utf8_proc.c', line 114
static VALUE StoNFKC_CF(VALUE string) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT | UTF8PROC_CASEFOLD);
}
|
#NFKD ⇒ Object
104 105 106 |
# File 'ext/utf8_proc/utf8_proc.c', line 104
static VALUE StoNFKD(VALUE string) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
}
|
#normalize(*args) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'ext/utf8_proc/utf8_proc.c', line 148
static VALUE StoNorm(int argc, VALUE* argv, VALUE string){
VALUE form;
rb_scan_args(argc, argv, "01", &form);
if (NIL_P(form)) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
}
ID s_form;
s_form = SYM2ID(form);
if (s_form == NFC) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
} else if (s_form == NFD) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE);
} else if (s_form == NFKC) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
} else if (s_form == NFKD) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
} else if (s_form == NFKC_CF) {
return normInternal(&string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT | UTF8PROC_CASEFOLD);
} else {
rb_raise(rb_eArgError, "%s",
"Argument must be one of [:nfc (default), :nfd, :nfkc, " \
":nfkd, :nfkc_cf]");
}
}
|