Ticket #859: poi_filter_unicode.diff

File poi_filter_unicode.diff, 993 bytes (added by https://wiki.navit-project.org/index.php/user:tryagain, 10 months ago)

Improved algorithm to use case- and accent- insensetive strings comparison. Unfortunately, it won't currently give any change for WinCE and any other platform using built-in copy of glib.

  • navit/gui/internal/gui_internal.c

     
    22562256removecase(char *s)  
    22572257{ 
    22582258        char *r; 
     2259#if HAVE_GLIB 
     2260        gchar *p1,*p2,*pp;       
     2261        r=g_utf8_normalize(s,-1,G_NORMALIZE_ALL); 
     2262        if(!r) { 
     2263                pp=g_strdup(s); 
     2264                if(!g_utf8_validate(pp,-1,&p1)) { 
     2265                        if(p1) { 
     2266                                dbg(0,"Invalid utf8 string %s will be cut at byte pos %d\n", p1-pp); 
     2267                                *p1=0; 
     2268                                r=g_utf8_normalize(s,-1,G_NORMALIZE_ALL); 
     2269                        } 
     2270                        if(!r) { 
     2271                                dbg(0,"Unable to fix broken utf8 string %s\n",s); 
     2272                                r=g_strdup(""); 
     2273                        } 
     2274                } 
     2275                g_free(pp); 
     2276        } 
     2277        for(p1=r,p2=r;*p1;) { 
     2278                gunichar c=g_utf8_get_char(p1); 
     2279                pp=g_utf8_next_char(p1); 
     2280                if(!g_unichar_iszerowidth(c)) { 
     2281                        memmove(p2,p1,pp-p1); 
     2282                        p2+=pp-p1; 
     2283                } 
     2284                p1=pp; 
     2285        } 
     2286        *p2=0; 
     2287        pp=g_utf8_casefold(r,-1); 
     2288        g_free(r); 
     2289        r=pp; 
     2290#else 
    22592291        r=g_utf8_casefold(s,-1); 
     2292#endif 
    22602293        return r; 
    22612294} 
    22622295