From 990838a226e8e2ac39adc388f46818c8425255b8 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Tue, 21 Apr 2009 21:27:42 +0000 Subject: [PATCH] fix: draw in core editor 8-bit locale and UTF-8 source --- edit/editdraw.c | 20 ++++++++++---------- src/charsets.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/edit/editdraw.c b/edit/editdraw.c index 037dda521..3da2d3b62 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -300,18 +300,18 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, lowlevel_set_color (color); } } -#ifndef HAVE_SLANG - int res = g_unichar_to_utf8 (textchar, str); - if ( res == 0 ) { - str[0] = '.'; - str[1] = '\0'; + if ( textchar > 255 ) { + int res = g_unichar_to_utf8 (textchar, str); + if ( res == 0 ) { + str[0] = '.'; + str[1] = '\0'; + } else { + str[res] = '\0'; + } + addstr (str); } else { - str[res] = '\0'; + addch(textchar); } - addstr (str); -#else - addch (textchar); -#endif p++; } } diff --git a/src/charsets.c b/src/charsets.c index 7956d3b37..aaced1f38 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -351,7 +351,7 @@ convert_from_utf_to_current_c (const int input_char) if ( res == 0 ) { return ch; } - str[6] = '\0'; + str[res] = '\0'; const char *cp_from = get_codepage_id ( source_codepage ); conv = str_crt_conv_from ( cp_from );