diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c index d2db73cc6..6b193829c 100644 --- a/src/core/wee-utf8.c +++ b/src/core/wee-utf8.c @@ -424,7 +424,15 @@ utf8_strlen_screen (const char *string) } if (mbstowcs (ptr_wstring, string, num_char) != (size_t)(-1)) + { length = wcswidth (ptr_wstring, num_char); + /* + * ensure the size is always >= 1, to prevent any display bug + * (for example size of UTF-8 char U+26C4 is -1, why? mystery...) + */ + if (length < 1) + length = 1; + } else length = utf8_strlen (string); diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 7219a6645..ba665ea7d 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -150,19 +150,11 @@ gui_chat_utf_char_valid (const char *utf_char) int gui_chat_char_size_screen (const char *utf_char) { - int size_screen; - /* if char is invalid, it will be displayed as one space on screen */ if (!gui_chat_utf_char_valid (utf_char)) return 1; - size_screen = utf8_char_size_screen (utf_char); - - /* - * ensure the size is always >= 1, to prevent any display bug - * (for example UTF-8 char U+26C4 returns size < 1) - */ - return (size_screen >= 1) ? size_screen : 1; + return utf8_char_size_screen (utf_char); } /*