Code

charset: moved code to unicode_char_width()
authorMax Kellermann <max@duempel.org>
Thu, 19 Nov 2009 20:05:17 +0000 (21:05 +0100)
committerMax Kellermann <max@duempel.org>
Thu, 19 Nov 2009 20:05:17 +0000 (21:05 +0100)
src/charset.c

index 6282fbf35167cc7015dafd7822c486934809a0b2..440084406d2f5837d239a356da48b5f068294a9f 100644 (file)
@@ -35,6 +35,17 @@ charset_init(void)
 }
 #endif
 
+#ifdef ENABLE_WIDE
+static inline unsigned
+unicode_char_width(gunichar ch)
+{
+       if (g_unichar_iswide(ch))
+               return 2;
+
+       return 1;
+}
+#endif /* ENABLE_WIDE */
+
 unsigned
 utf8_width(const char *str)
 {
@@ -51,7 +62,7 @@ utf8_width(const char *str)
 
                while (len--) {
                        c = g_utf8_get_char(str);
-                       width += g_unichar_iswide(c) ? 2 : 1;
+                       width += unicode_char_width(c);
                        str += g_unichar_to_utf8(c, NULL);
                }