~chihchun/zim/zim.lp918569

« back to all changes in this revision

Viewing changes to zim/index.py

  • Committer: Jaap Karssenberg
  • Date: 2013-04-08 19:50:19 UTC
  • Revision ID: pardus@cpan.org-20130408195019-00vvsw6cm05bx00z
Fixes for matching unicode strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
import sqlite3
89
89
import gobject
 
90
import unicodedata
90
91
import logging
91
92
 
92
93
import zim
1412
1413
                                        return None
1413
1414
                        elif name in rows: # exact match
1414
1415
                                row = rows[name]
1415
 
                        else: # take first insensitive match based on sorting
 
1416
                        elif unicodedata.normalize('NFC', name) in rows:
 
1417
                                name = unicodedata.normalize('NFC', name)
 
1418
                                row = rows[name]
 
1419
                        elif unicodedata.normalize('NFD', name) in rows:
 
1420
                                name = unicodedata.normalize('NFD', name)
 
1421
                                row = rows[name]
 
1422
                        else:
 
1423
                                # take first match based on sorting
 
1424
                                # case insensitive or unicode compatibility (NFKD / NFKC)
1416
1425
                                n = rows.keys()
1417
1426
                                n.sort()
1418
1427
                                row = rows[n[0]]