From 8767909493e94d98a5a2fc7d1417ce5fefa82be9 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Fri, 17 Apr 2009 06:17:37 +0000 Subject: [PATCH] fix incorrect draw utf-8 text in 8-bit locale --- edit/editdraw.c | 2 +- src/charsets.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/edit/editdraw.c b/edit/editdraw.c index 6de7617c6..340470d30 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -434,10 +434,10 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, default: if ( utf8_display ) { if ( !edit->utf8 ) { - //c = convert_from_utf_to_current_c (c); } } else { if ( edit->utf8 ) { + c = convert_from_utf_to_current_c (c); //c = convert_to_utf (c); } else { c = convert_to_display_c (c); diff --git a/src/charsets.c b/src/charsets.c index 2db761d74..9f55dcf47 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -284,14 +284,19 @@ convert_from_utf_to_current (const char *str) unsigned char convert_from_utf_to_current_c (const int input_char) { - unsigned char str[2]; + unsigned char str[6 + 1]; unsigned char ch = '.'; + char *cp_to = NULL; GIConv conv; GString *translated_data; + int res = 0; - str[0] = input_char; - str[1] = '\0'; + res = g_unichar_to_utf8 (input_char, str); + if ( res == 0 ) { + return ch; + } + str[6] = '\0'; translated_data = g_string_new (""); cp_to = g_strdup ( get_codepage_id ( display_codepage ) );