Fix ICU contractions

This commit is contained in:
Kovid Goyal 2012-07-05 20:38:03 +05:30
parent 223cfd8f12
commit d5fa5cf07d
2 changed files with 10 additions and 2 deletions

View File

@ -241,7 +241,7 @@ icu_Collator_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs)
if (self->contractions == NULL) { if (self->contractions == NULL) {
self->contractions = uset_open(1, 0); self->contractions = uset_open(1, 0);
if (self->contractions == NULL) return PyErr_NoMemory(); if (self->contractions == NULL) return PyErr_NoMemory();
ucol_getContractionsAndExpansions(self->collator, self->contractions, NULL, 0, &status); self->contractions = ucol_getTailoredSet(self->collator, &status);
} }
status = U_ZERO_ERROR; status = U_ZERO_ERROR;
@ -290,7 +290,7 @@ icu_Collator_span_contractions(icu_Collator *self, PyObject *args, PyObject *kwa
if (self->contractions == NULL) { if (self->contractions == NULL) {
self->contractions = uset_open(1, 0); self->contractions = uset_open(1, 0);
if (self->contractions == NULL) return PyErr_NoMemory(); if (self->contractions == NULL) return PyErr_NoMemory();
ucol_getContractionsAndExpansions(self->collator, self->contractions, NULL, 0, &status); self->contractions = ucol_getTailoredSet(self->collator, &status);
} }
status = U_ZERO_ERROR; status = U_ZERO_ERROR;

View File

@ -315,6 +315,14 @@ pêché'''
print 'Primary collation in Spanish locale failed' print 'Primary collation in Spanish locale failed'
return return
print '\nTesting contractions'
c = _icu.Collator('cs')
if icu_contractions(c) != frozenset([u'Z\u030c', u'z\u030c', u'Ch',
u'C\u030c', u'ch', u'cH', u'c\u030c', u's\u030c', u'r\u030c', u'CH',
u'S\u030c', u'R\u030c']):
print 'Contractions for the Czech language failed'
return
# }}} # }}}
if __name__ == '__main__': if __name__ == '__main__':