--- lbbs/src/str_process.c 2025/11/08 08:21:31 1.28 +++ lbbs/src/str_process.c 2025/11/11 00:28:05 1.30 @@ -6,6 +6,10 @@ * Copyright (C) 2004-2025 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "common.h" #include "log.h" #include "str_process.h" @@ -72,9 +76,15 @@ int str_length(const char *str, int skip if (mbstowcs(wcs, input_str, 1) == (size_t)-1) { +#ifdef _DEBUG log_error("mbstowcs(%s) error\n", input_str); +#endif + wc_len = (UTF8_fixed_width ? 2 : 1); // Fallback + } + else + { + wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); } - wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); i += (str_len - 1); ret += wc_len; @@ -132,9 +142,16 @@ int split_line(const char *buffer, int m if (mbstowcs(wcs, input_str, 1) == (size_t)-1) { +#ifdef _DEBUG log_error("mbstowcs(%s) error\n", input_str); +#endif + wc_len = (UTF8_fixed_width ? 2 : 1); // Fallback } - wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); + else + { + wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0])); + } + if (*p_display_len + wc_len > max_display_len) { break;