diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/utf8.h | 1 | ||||
-rw-r--r-- | src/fe-common/irc/fe-ircnet.c | 2 | ||||
-rw-r--r-- | src/fe-text/textbuffer.c | 12 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/fe-common/core/utf8.h b/src/fe-common/core/utf8.h index 163f1717..3c15dc7d 100644 --- a/src/fe-common/core/utf8.h +++ b/src/fe-common/core/utf8.h @@ -12,5 +12,6 @@ int mk_wcwidth(unichar c); #define unichar_isprint(c) (((c) & ~0x80) >= 32) +#define is_utf8_leading(c) (((c) & 0xc0) != 0x80) #endif diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c index b35ae898..6618edd7 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -82,7 +82,7 @@ static void cmd_network_list(void) } /* SYNTAX: NETWORK ADD [-nick <nick>] [-user <user>] [-realname <name>] - [-host <host>] [-autosendcmd <cmd>] + [-host <host>] [-usermode <mode>] [-autosendcmd <cmd>] [-querychans <count>] [-whois <count>] [-msgs <count>] [-kicks <count>] [-modes <count>] [-cmdspeed <ms>] [-cmdmax <count>] <name> */ diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c index 0ba7d16e..69f5969c 100644 --- a/src/fe-text/textbuffer.c +++ b/src/fe-text/textbuffer.c @@ -23,6 +23,7 @@ #include "module.h" #include "misc.h" #include "formats.h" +#include "utf8.h" #include "textbuffer.h" @@ -154,6 +155,17 @@ static void text_chunk_append(TEXT_BUFFER_REC *buffer, chunk = buffer->cur_text; while (chunk->pos + len >= TEXT_CHUNK_USABLE_SIZE) { left = TEXT_CHUNK_USABLE_SIZE - chunk->pos; + + /* don't split utf-8 character. (assume we can split non-utf8 anywhere.) */ + if (left < len && !is_utf8_leading(data[left])) { + int i; + for (i = 1; i < 4 && left >= i; i++) + if (is_utf8_leading(data[left - i])) { + left -= i; + break; + } + } + if (left > 0 && data[left-1] == 0) left--; /* don't split the commands */ |