summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tab.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/tab.c b/src/tab.c
index 80d3972..fe1096a 100644
--- a/src/tab.c
+++ b/src/tab.c
@@ -456,19 +456,26 @@ init_non_root(const gchar *uri)
static void
scroll_tab_label(MqTab *tab)
{
- gchar c;
+ gchar c[5]; /* Up to 4 bytes for a UTF-8 character, plus NUL */
guint i;
+ guint j;
- /* Save the first character. */
- c = tab->scrolled_title[0];
+ /* Save the first (possibly multibyte) character. */
+ c[0] = tab->scrolled_title[0];
+ for (i = 1; tab->scrolled_title[i] & 0x80; ++i) {
+ c[i] = tab->scrolled_title[i];
+ }
+ c[i] = '\0';
/* Shift all characters. */
- for (i = 1; tab->scrolled_title[i]; ++i) {
- tab->scrolled_title[i - 1] = tab->scrolled_title[i];
+ for (j = 0; tab->scrolled_title[i]; ++i, ++j) {
+ tab->scrolled_title[j] = tab->scrolled_title[i];
}
- /* Set the last character. */
- tab->scrolled_title[i - 1] = c;
+ /* Set the last (possibly multibyte) character. */
+ for (--j, i = 0; c[i]; ++i, ++j) {
+ tab->scrolled_title[j] = c[i];
+ }
update_tab_label(tab);
}