View Single Post
Old 12-03-2010, 11:11 AM   #18
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,423
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
This is fairly simple to do. What you have to implement is a python C extension that defines a cmp function that compares two unicode objects. Given that integrating it into calibre would be trivial.

In psedo-code the thing would look like:

Code:
function set_collation(lang_code) {
...
}

function cmp(a, b) {
return a - b; //Where a -b means return -1 if a < b, +i if a > b and 0 if a==b
}
It should be possible to link the extension against ICU and use that to implement cmp, though that would require that ICU be compilable on win/linux/osx.
kovidgoyal is offline   Reply With Quote