summaryrefslogtreecommitdiff
path: root/src/plugins/logger
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-05-03 12:36:27 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-05-03 12:36:27 +0200
commitdfbe7845ae7ad0531d3d7488b0fbdd73f073574e (patch)
tree45c99fb753981797d4e5faed659cc8439f2b8898 /src/plugins/logger
parent3d738051982f4c1c7d9154baa7d8d9c000087281 (diff)
downloadweechat-dfbe7845ae7ad0531d3d7488b0fbdd73f073574e.zip
logger: fix charset of lines displayed in backlog when terminal charset is different from UTF-8 (bug #36379)
Diffstat (limited to 'src/plugins/logger')
-rw-r--r--src/plugins/logger/logger.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 7c440e813..f5dad66d2 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -914,12 +914,15 @@ logger_buffer_renamed_signal_cb (void *data, const char *signal,
void
logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
{
+ const char *charset;
struct t_logger_line *last_lines, *ptr_lines;
- char *pos_message, *pos_tab, *error;
+ char *pos_message, *pos_tab, *error, *message;
time_t datetime, time_now;
struct tm tm_line;
int num_lines;
+ charset = weechat_info_get ("charset_terminal", "");
+
weechat_buffer_set (buffer, "print_hooks_enabled", "0");
num_lines = 0;
last_lines = logger_tail_file (filename, lines);
@@ -949,19 +952,25 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
}
pos_message = (pos_message && (datetime != 0)) ?
pos_message + 1 : ptr_lines->data;
- pos_tab = strchr (pos_message, '\t');
- if (pos_tab)
- pos_tab[0] = '\0';
- weechat_printf_date_tags (buffer, datetime,
- "no_highlight,notify_none",
- "%s%s%s%s%s",
- weechat_color (weechat_config_string (logger_config_color_backlog_line)),
- pos_message,
- (pos_tab) ? "\t" : "",
- (pos_tab) ? weechat_color (weechat_config_string (logger_config_color_backlog_line)) : "",
- (pos_tab) ? pos_tab + 1 : "");
- if (pos_tab)
- pos_tab[0] = '\t';
+ message = (charset) ?
+ weechat_iconv_to_internal (charset, pos_message) : strdup (pos_message);
+ if (message)
+ {
+ pos_tab = strchr (message, '\t');
+ if (pos_tab)
+ pos_tab[0] = '\0';
+ weechat_printf_date_tags (buffer, datetime,
+ "no_highlight,notify_none",
+ "%s%s%s%s%s",
+ weechat_color (weechat_config_string (logger_config_color_backlog_line)),
+ message,
+ (pos_tab) ? "\t" : "",
+ (pos_tab) ? weechat_color (weechat_config_string (logger_config_color_backlog_line)) : "",
+ (pos_tab) ? pos_tab + 1 : "");
+ if (pos_tab)
+ pos_tab[0] = '\t';
+ free (message);
+ }
num_lines++;
ptr_lines = ptr_lines->next_line;
}