mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
core: move test of invalid UTF-8 char length from gui-chat.c to wee-utf8.c
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
+1
-9
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user