[empathy] Make livesearch work if accentued letters are pre-decomposed



commit fa60b75334999bedb28dfacdbb5a73f1cc62193a
Author: Xavier Claessens <xclaesse gmail com>
Date:   Thu Jul 22 15:02:06 2010 +0200

    Make livesearch work if accentued letters are pre-decomposed

 libempathy-gtk/empathy-live-search.c |   12 ++++++------
 tests/empathy-live-search-test.c     |    7 ++++++-
 2 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/libempathy-gtk/empathy-live-search.c b/libempathy-gtk/empathy-live-search.c
index e0f5e19..8a627ea 100644
--- a/libempathy-gtk/empathy-live-search.c
+++ b/libempathy-gtk/empathy-live-search.c
@@ -84,7 +84,9 @@ stripped_char (gunichar ch)
     case G_UNICODE_CONTROL:
     case G_UNICODE_FORMAT:
     case G_UNICODE_UNASSIGNED:
+    case G_UNICODE_NON_SPACING_MARK:
     case G_UNICODE_COMBINING_MARK:
+    case G_UNICODE_ENCLOSING_MARK:
       /* Ignore those */
       break;
     default:
@@ -120,16 +122,14 @@ strip_utf8_string (const gchar *string)
       /* Strip this word */
       while (*p != '\0')
         {
-          gunichar c;
           gunichar sc;
 
-          c = g_utf8_get_char (p);
-          if (!g_unichar_isalnum (c))
-            break;
-
-          sc = stripped_char (c);
+          sc = stripped_char (g_utf8_get_char (p));
           if (sc != 0)
             {
+              if (!g_unichar_isalnum (sc))
+                break;
+
               if (str == NULL)
                 str = g_string_new (NULL);
               g_string_append_unichar (str, sc);
diff --git a/tests/empathy-live-search-test.c b/tests/empathy-live-search-test.c
index 6401f25..377470e 100644
--- a/tests/empathy-live-search-test.c
+++ b/tests/empathy-live-search-test.c
@@ -29,12 +29,17 @@ test_live_search (void)
       { "Hello-World", "wo", TRUE },
       { "HelloWorld", "wo", FALSE },
 
-      /* Test accentued letters */
+      /* Test composed chars (accentued letters) */
       { "Jörgen", "jor", TRUE },
       { "Gaëtan", "gaetan", TRUE },
       { "élève", "ele", TRUE },
       { "Azais", "AzaÃ?s", TRUE },
 
+      /* Test decomposed chars, they looks the same, but are actually
+       * composed of multiple unicodes */
+      { "Jorgen", "JoÌ?r", TRUE },
+      { "JoÌ?rgen", "jor", TRUE },
+
       /* Multi words */
       { "Xavier Claessens", "Xav Cla", TRUE },
       { "Xavier Claessens", "Cla Xav", TRUE },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]