Re: incorrect hex number in editor [patch]



Here you are. Apply it after the big utf8 patch.


-- 
Egmont
diff -Naur mc-4.6.1.orig/edit/editdraw.c mc-4.6.1/edit/editdraw.c
--- mc-4.6.1.orig/edit/editdraw.c	2006-09-05 13:14:51.000000000 +0200
+++ mc-4.6.1/edit/editdraw.c	2006-09-05 13:42:50.000000000 +0200
@@ -57,12 +57,22 @@
      */
     if (edit->curs1 < edit->last_byte) {
         mc_wchar_t cur_byte = edit_get_byte (edit, edit->curs1);
+        mc_wchar_t cur_byte2 = cur_byte;
 #ifndef UTF8
 	g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
 		    is_printable (cur_byte) ? cur_byte : '.',
 #else /* UTF8 */
+        /* In 8-bit locales show the byte itself instead of its Unicode value */
+        if (MB_CUR_MAX == 1) {
+            unsigned char cur_8bit_byte;
+            mbstate_t mbs;
+            memset (&mbs, 0, sizeof (mbs));
+            if (wcrtomb(&cur_8bit_byte, cur_byte, &mbs) == 1) {
+                cur_byte = cur_8bit_byte;
+            }
+        }
         g_snprintf (byte_str, sizeof(byte_str), "%lc %3d 0x%02X",
-                    iswprint(cur_byte) ? cur_byte : '.',
+                    iswprint(cur_byte2) ? cur_byte2 : '.',
 #endif /* UTF8 */
                     (int) cur_byte,
                     (unsigned) cur_byte);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]