From 8742b05f21c869315085bac96f869fa20f273a63 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Wed, 7 Jul 2010 18:28:06 +0000 Subject: [PATCH] Ticket #2263 (hex viewer: non ASCII fix) viewer does not show non ASCII characters in HEX mode. Signed-off-by: Ilia Maslakov --- src/viewer/hex.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/viewer/hex.c b/src/viewer/hex.c index 5bd26d773..07eae624f 100644 --- a/src/viewer/hex.c +++ b/src/viewer/hex.c @@ -282,46 +282,40 @@ mcview_display_hex (mcview_t * view) /* boldflag == MARK_CURSOR */ view->hexview_in_text ? VIEW_UNDERLINED_COLOR : MARKED_SELECTED_COLOR); + #ifdef HAVE_CHARSET if (utf8_display) { if (!view->utf8) { - ch = convert_from_8bit_to_utf_c ((unsigned char) ch, view->converter); + c = convert_from_8bit_to_utf_c ((unsigned char) c, view->converter); } - if (!g_unichar_isprint (ch)) - ch = '.'; + if (!g_unichar_isprint (c)) + c = '.'; } + else if (view->utf8) + ch = convert_from_utf_to_current_c (ch, view->converter); else +#endif { - if (view->utf8) - { - ch = convert_from_utf_to_current_c (ch, view->converter); - } - else - { -#endif - ch = convert_to_display_c (ch); -#ifdef HAVE_CHARSET - } + c = convert_to_display_c (c); + + if (!is_printable (c)) + c = '.'; } -#endif - c = convert_to_display_c (c); - if (!g_ascii_isprint (c)) - c = '.'; /* Print corresponding character on the text side */ if (text_start + bytes < width) { widget_move (view, top + row, left + text_start + bytes); - if (!view->utf8) +#ifdef HAVE_CHARSET + if (view->utf8) + tty_print_anychar (ch); + else +#endif { tty_print_char (c); } - else - { - tty_print_anychar (ch); - } } /* Save the cursor position for mcview_place_cursor() */