From 7e143ef869976b729aa11e3ec93033b4f9f41a22 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 19 Nov 2009 21:05:17 +0100 Subject: [PATCH] charset: moved code to unicode_char_width() --- src/charset.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/charset.c b/src/charset.c index 6282fbf..4400844 100644 --- a/src/charset.c +++ b/src/charset.c @@ -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); } -- 2.30.2