Ignore:
Timestamp:
28.07.2010 22:00:49 (22 months ago)
Author:
zmsdev
Message:

Applied fix for searching german-umlauts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ZMS/trunk/_zcatalogmanager.py

    r1124 r1126  
    6666    elif type(v) is list: 
    6767      for i in v: 
    68         s += search_string(i) 
     68        s += search_string(i) + ' ' 
    6969    elif type(v) is dict: 
    7070      for k in v.keys(): 
    7171        i = v[k] 
    72         s += search_string(i) 
     72        s += search_string(i) + ' ' 
    7373  return s 
    7474 
     
    122122      pass 
    123123 
    124  
    125124# -------------------------------------------------------------------------- 
    126125#  _zcatalogmanager.getCatalog: 
     
    199198    # -------------------------------------------------------------------------- 
    200199    def search_encode(self, s): 
    201       try: 
    202         s = unicode( s, 'utf-8').encode( 'latin-1') 
    203         # German Umlauts in capital letters. 
    204         mapping = { 
    205           '\xc4':'\xe4', # Ae 
    206           '\xd6':'\xf6', # Oe 
    207           '\xdc':'\xfc', # Ue 
    208         } 
    209         for capital in mapping.keys(): 
    210           letter = mapping[ capital] 
    211           while s.find( capital) >= 0: 
    212             s = s.replace( capital, letter) 
    213       except ( UnicodeDecodeError, UnicodeEncodeError): 
    214         _globals.writeError(self,"[search_encode]") 
    215         try: 
    216           v = str(sys.exc_value) 
    217           STR_POSITION = ' position ' 
    218           i = v.find(STR_POSITION) 
    219           if i > 0: 
    220             v = v[i+len(STR_POSITION):] 
    221             if v.find('-') > 0: 
    222               l = int( v[:v.find('-')]) 
    223               h = int( v[v.find('-')+1:v.find(':')]) 
    224             else: 
    225               l = int( v[:v.find(':')]) 
    226               h = l 
    227             ln = max( l - 20, 0) 
    228             hn = min( h + 20, len(s)) 
    229             print ">>>>>",s[ln:hn] 
    230             print ">>>>>"," "*(l-ln)+"^"*(h-l+1) 
    231         except: 
    232           _globals.writeError(self,"[search_encode]: ignore exception") 
    233       return s 
     200      return _globals.umlaut_quote(s) 
    234201 
    235202 
Note: See TracChangeset for help on using the changeset viewer.