Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#transliterate(transform) ⇒ Object
string.transliterate(transform_string) -> string.
-
#unicode_sort_key ⇒ Object
string.unicode_sort_key -> string.
Instance Method Details
#transliterate(transform) ⇒ Object
string.transliterate(transform_string) -> string
Transliterates string using transform.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'ext/icunicode.c', line 90
static VALUE unicode_transliterate(VALUE string, VALUE transform) {
UChar str[BUF_SIZE];
int32_t slen = 0;
UErrorCode status = U_ZERO_ERROR;
UTransliterator *trans;
VALUE tobj;
to_utf16(string, str, &slen);
trans = get_trans(transform);
utrans_transUChars(trans, str, &slen, BUF_SIZE, 0, &slen, &status);
to_utf8(str, slen);
}
|
#unicode_sort_key ⇒ Object
string.unicode_sort_key -> string
Returns a string that will sort according to the Unicode collation algorithm.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'ext/icunicode.c', line 37
static VALUE unicode_sort_key(VALUE string) {
char str[BUF_SIZE];
UChar ustr[BUF_SIZE];
int32_t len = 0;
int32_t ulen = 0;
UErrorCode status = U_ZERO_ERROR;
UCollator *col;
to_utf16(string, ustr, &ulen);
col = ucol_open("en_US", &status);
if (U_SUCCESS(status)) {
len = ucol_getSortKey(col, ustr, ulen, (uint8_t*)str, BUF_SIZE);
ucol_close(col);
}
return rb_str_new(str, len - 1);
}
|