From: Max Kellermann Date: Thu, 19 Nov 2009 20:05:17 +0000 (+0100) Subject: charset: moved code to unicode_char_width() X-Git-Tag: release-0.16~22 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7e143ef869976b729aa11e3ec93033b4f9f41a22;hp=eb4967eab943e8ba74279864c23d980ac10c753c;p=ncmpc.git charset: moved code to unicode_char_width() --- 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); }