[pyicu-dev] getCollationKey
Andi Vajda
vajda at osafoundation.org
Fri Nov 18 09:26:58 PST 2005
> It's great to see a Python binding for ICU underway!
Thanks, it's definitely work in progress.
> Is the getCollationKey method of collators usable? If so, how
> is it called?
You found a bug. I fixed in rev 47. Here is how you'd use it:
>>> from PyICU import *
>>> c=Collator.createInstance()
>>> ck=CollationKey()
>>> ck1=CollationKey()
>>> c.getCollationKey('a string', ck)
<PyICU_collator.CollationKey; proxy of C++ icu::CollationKey instance at
<PyCObject object at 0xf308>>
>>> c.getCollationKey('another string', ck1)
<PyICU_collator.CollationKey; proxy of C++ icu::CollationKey instance at
<PyCObject object at 0xf1e8>>
>>> ck.compareTo(ck1)
-1
>>> ck1.compareTo(ck)
1
>>>
The collation key instance returned from getCollationKey() is the one you
passed in:
>>> ck1 is c.getCollationKey('another string', ck1)
True
Andi..
More information about the pyicu-dev
mailing list