Ticket #2263 (hex viewer: non ASCII fix)

viewer does not show non ASCII characters in HEX mode.

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
Ilia Maslakov 2010-07-07 18:28:06 +00:00
parent b3bd656fe4
commit 8742b05f21

View File

@ -282,46 +282,40 @@ mcview_display_hex (mcview_t * view)
/* boldflag == MARK_CURSOR */ /* boldflag == MARK_CURSOR */
view->hexview_in_text ? VIEW_UNDERLINED_COLOR : MARKED_SELECTED_COLOR); view->hexview_in_text ? VIEW_UNDERLINED_COLOR : MARKED_SELECTED_COLOR);
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
if (utf8_display) if (utf8_display)
{ {
if (!view->utf8) 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)) if (!g_unichar_isprint (c))
ch = '.'; c = '.';
} }
else if (view->utf8)
ch = convert_from_utf_to_current_c (ch, view->converter);
else else
#endif
{ {
if (view->utf8) c = convert_to_display_c (c);
{
ch = convert_from_utf_to_current_c (ch, view->converter); if (!is_printable (c))
} c = '.';
else
{
#endif
ch = convert_to_display_c (ch);
#ifdef HAVE_CHARSET
}
} }
#endif
c = convert_to_display_c (c);
if (!g_ascii_isprint (c))
c = '.';
/* Print corresponding character on the text side */ /* Print corresponding character on the text side */
if (text_start + bytes < width) if (text_start + bytes < width)
{ {
widget_move (view, top + row, left + text_start + bytes); 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); tty_print_char (c);
} }
else
{
tty_print_anychar (ch);
}
} }
/* Save the cursor position for mcview_place_cursor() */ /* Save the cursor position for mcview_place_cursor() */