Module: UTF8Proc
- Defined in:
- lib/utf8_proc.rb,
lib/utf8_proc/version.rb,
ext/utf8_proc/utf8_proc.c
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
- .NFC(string) ⇒ Object
- .NFD(string) ⇒ Object
- .NFKC(string) ⇒ Object
- .NFKC_CF(string) ⇒ Object
- .NFKD(string) ⇒ Object
- .normalize(*args) ⇒ Object
Class Method Details
.NFC(string) ⇒ Object
32 33 34 |
# File 'ext/utf8_proc/utf8_proc.c', line 32
VALUE toNFC(VALUE self, VALUE string) {
return normInternal(string, UTF8PROC_STABLE | UTF8PROC_COMPOSE);
}
|
.NFD(string) ⇒ Object
36 37 38 |
# File 'ext/utf8_proc/utf8_proc.c', line 36
VALUE toNFD(VALUE self, VALUE string) {
return normInternal(string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE);
}
|
.NFKC(string) ⇒ Object
40 41 42 |
# File 'ext/utf8_proc/utf8_proc.c', line 40
VALUE toNFKC(VALUE self, VALUE string) {
return normInternal(string,UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT);
}
|
.NFKC_CF(string) ⇒ Object
48 49 50 |
# File 'ext/utf8_proc/utf8_proc.c', line 48
VALUE toNFKC_CF(VALUE self, VALUE string) {
return normInternal(string, UTF8PROC_STABLE | UTF8PROC_COMPOSE | UTF8PROC_COMPAT | UTF8PROC_CASEFOLD);
}
|
.NFKD(string) ⇒ Object
44 45 46 |
# File 'ext/utf8_proc/utf8_proc.c', line 44
VALUE toNFKD(VALUE self, VALUE string) {
return normInternal(string, UTF8PROC_STABLE | UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
}
|
.normalize(*args) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'ext/utf8_proc/utf8_proc.c', line 53
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 = 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_eRuntimeError, "%s",
"Second optional argument must be one of [:nfc, :nfd, :nfkc, :nfkd, :nfkc_cf] (defaults to :nfc)");
}
}
|