[gnome-characters/wip/properties: 6/9] libgc: Add accessor to canonical decomposition



commit 4865128f05957a67d71cbeb3d2204442080416d4
Author: Daiki Ueno <ueno gnu org>
Date:   Mon Feb 9 18:41:27 2015 +0900

    libgc: Add accessor to canonical decomposition

 lib/gc.c |   28 ++++++++++++++++++++++++++++
 lib/gc.h |    2 ++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/lib/gc.c b/lib/gc.c
index 65467c2..2607325 100644
--- a/lib/gc.c
+++ b/lib/gc.c
@@ -442,6 +442,34 @@ gc_character_block (gunichar uc)
   return block->name;
 }
 
+/**
+ * gc_character_decomposition:
+ * @uc: a UCS-4 character
+ *
+ * Returns: (transfer full): the canonical charactera decomposition
+ * mapping of @uc.
+ */
+GcSearchResult *
+gc_character_decomposition (gunichar uc)
+{
+  ucs4_t decomposition[UC_DECOMPOSITION_MAX_LENGTH];
+  int retval, i;
+  GArray *result;
+
+  result = g_array_new (FALSE, FALSE, sizeof (gunichar));
+
+  retval = uc_canonical_decomposition (uc, decomposition);
+  if (retval > 0)
+    {
+      /* Don't use g_array_append_vals, since the size of ucs4_t may
+        differ from gunichar's.  */
+      for (i = 0; i < retval; i++)
+       g_array_append_val (result, decomposition[i]);
+    }
+
+  return result;
+}
+
 G_DEFINE_BOXED_TYPE (GcSearchResult, gc_search_result,
                     g_array_ref, g_array_unref);
 
diff --git a/lib/gc.h b/lib/gc.h
index a35df9d..008f451 100644
--- a/lib/gc.h
+++ b/lib/gc.h
@@ -61,6 +61,8 @@ gchar          *gc_character_name         (gunichar              uc);
 const gchar    *gc_character_category     (gunichar              uc);
 const gchar    *gc_character_script       (gunichar              uc);
 const gchar    *gc_character_block        (gunichar              uc);
+GcSearchResult *gc_character_decomposition
+                                          (gunichar              uc);
 
 /* GTK+ support.  gtk_clipboard_get() takes an GdkAtom as the first
    argument, but GdkAtom is not accessible through GI.  */


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