Index: glib/gunicode.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gunicode.h,v
retrieving revision 1.33
diff -u -p -d -r1.33 gunicode.h
--- glib/gunicode.h	27 Apr 2006 21:14:46 -0000	1.33
+++ glib/gunicode.h	16 Jul 2006 03:16:33 -0000
@@ -137,6 +137,8 @@ gboolean g_unichar_istitle   (gunichar c
 gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST;
 gboolean g_unichar_iswide    (gunichar c) G_GNUC_CONST;
 gboolean g_unichar_iswide_cjk(gunichar c) G_GNUC_CONST;
+int      g_unichar_get_width (gunichar c) G_GNUC_CONST;
+int  g_unichar_get_width_cjk (gunichar c) G_GNUC_CONST;
 
 /* More <ctype.h> functions.  These convert between the three cases.
  * See the Unicode book to understand title case.  */
Index: glib/guniprop.c
===================================================================
RCS file: /cvs/gnome/glib/glib/guniprop.c,v
retrieving revision 1.44
diff -u -p -d -r1.44 guniprop.c
--- glib/guniprop.c	3 May 2006 02:04:55 -0000	1.44
+++ glib/guniprop.c	16 Jul 2006 03:16:33 -0000
@@ -89,6 +89,11 @@
 			    OR (G_UNICODE_COMBINING_MARK,	\
 			    OR (G_UNICODE_ENCLOSING_MARK,	0))))
 
+#define ISZEROWIDTHTYPE(Type)	IS ((Type),			\
+			    OR (G_UNICODE_NON_SPACING_MARK,	\
+			    OR (G_UNICODE_ENCLOSING_MARK,	\
+			    OR (G_UNICODE_FORMAT,		0))))
+
 /**
  * g_unichar_isalnum:
  * @c: a Unicode character
@@ -353,6 +358,75 @@ gboolean
 g_unichar_isdefined (gunichar c)
 {
   return TYPE (c) != G_UNICODE_UNASSIGNED;
+}
+
+static gboolean
+_g_unichar_iszerowidth (gunichar c)
+{
+  if (G_UNLIKELY (c == 0x00AD))
+    return FALSE;
+
+  if (G_UNLIKELY (ISZEROWIDTHTYPE (c)))
+    return TRUE;
+
+  if (G_UNLIKELY ((c >= 0x1160 && c < 0x1200) ||
+		  c == 0x200B))
+    return TRUE;
+
+  return FALSE;
+}
+
+/**
+ * g_unichar_get_width:
+ * @c: a Unicode character
+ * 
+ * Finds the number of cells the character occupies when displayed on a
+ * grid display (terminals).  The return value is 0 for all non-spacing and
+ * enclosing marks (e.g., combining accents), format characters, zero-width
+ * space but not U+00AD SOFT HYPHEN;  2 for wide characters as
+ * determined by g_unichar_iswide(); and 1 for all other input values.
+ *
+ * Note that most terminals do not support zero-width rendering of zero-width
+ * marks.
+ * 
+ * Return value: the number of cells the character occupies
+ *
+ * Since: 2.14
+ **/
+int
+g_unichar_get_width (gunichar c)
+{
+  if (G_UNLIKELY (g_unichar_iszerowidth (c)))
+    return 0;
+
+  if (g_unichar_iswide (c))
+    return 2;
+
+  return 1;
+}
+
+/**
+ * g_unichar_get_width_cjk:
+ * @c: a Unicode character
+ * 
+ * This is like g_unichar_get_width(), but uses g_unichar_iswide_cjk()
+ * instead of g_unichar_iswide() to determine characters with width 2.
+ * 
+ * Return value: the number of cells the character occupies under
+ * legacy East Asian systems
+ *
+ * Since: 2.14
+ **/
+int
+g_unichar_get_width_cjk (gunichar c)
+{
+  if (G_UNLIKELY (g_unichar_iszerowidth (c)))
+    return 0;
+
+  if (g_unichar_iswide_cjk (c))
+    return 2;
+
+  return 1;
 }
 
 /**
