From 2fdb3689e2bed32acced527a54c6301db64b9ce4 Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Wed, 15 Apr 2009 18:14:17 +0000 Subject: [PATCH] fix: with status_string on utf-8 char --- edit/edit.c | 3 +-- edit/editdraw.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/edit/edit.c b/edit/edit.c index 27017b967..faf39db8f 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -164,12 +164,11 @@ int edit_get_utf (WEdit * edit, long byte_index, int *char_width) int width = 0; if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) { - *char_width = 1; + *char_width = 0; return '\n'; } str = edit_get_byte_ptr (edit, byte_index); - res = g_utf8_get_char_validated (str, -1); if ( res < 0 ) { diff --git a/edit/editdraw.c b/edit/editdraw.c index 96ebdea44..c0b36ddca 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -73,11 +73,22 @@ static void status_string (WEdit * edit, char *s, int w) * as decimal and as hex. */ if (edit->curs1 < edit->last_byte) { - unsigned char cur_byte = edit_get_byte (edit, edit->curs1); - g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X", - is_printable (cur_byte) ? cur_byte : '.', - (int) cur_byte, - (unsigned) cur_byte); + if ( !edit->utf8 ) { + unsigned char cur_byte = edit_get_byte (edit, edit->curs1); + g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X", + is_printable (cur_byte) ? cur_byte : '.', + (int) cur_byte, + (unsigned) cur_byte); + } else { + int cw = 1; + unsigned int cur_utf = edit_get_utf (edit, edit->curs1, &cw); + if ( cw > 0 ) { + g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X", + (unsigned) cur_utf, + (unsigned) cur_utf); + } + + } } else { strcpy (byte_str, ""); }