Alexander E. Patrakov пишет:
UTF-8 is _still_ not fully supported (e.g. 'tr :upper: :lower:' works only on ASCII characters, 'watch' shows only ASCII characters, 'sfdisk' misaligns button labels in non-English UTF-8 locales), but the same bugs exist in all distros (including those which claim that they support only UTF-8). Because of that, such bugs should not be an obstacle.

Hello, this patch fix UTF-8 issue with `watch` at least in ru_RU.UTF-8 and be_BY.UTF-8.
--- procps-3.2.6/watch.c        2005-10-30 02:44:53.000000000 +0300
+++ procps-3.2.6.UTF-8/watch.c  2006-01-01 11:54:35.000000000 +0200
@@ -25,6 +25,7 @@
 #include <termios.h>
 #include <locale.h>
 #include "proc/procps.h"
+#include <wctype.h>
 
 #ifdef FORCE_8BIT
 #undef isprint
@@ -274,9 +275,16 @@
                                        /* if there is a tab pending, just spit 
spaces until the
                                           next stop instead of reading 
characters */
                                        if (!tabpending)
-                                               do
+                                               do {
                                                        c = getc(p);
-                                               while (c != EOF && !isprint(c)
+                                                       if (c > 127) {
+                                                               c = ((c ^ 192) 
<< 6) + (getc(p) ^ 128);
+                                                       } else if (c > 223) {
+                                                               c = ((c ^ 224) 
<< 12) + ((getc(p) ^ 128) << 6) + (getc(p) ^ 128);
+                                                       } else if (c > 239) {
+                                                               c = ((c ^ 240) 
<< 18) + ((getc(p) ^ 128) << 12) + ((getc(p) ^ 128) << 6) + (getc(p) ^ 128);
+                                                       }
+                                               } while (c != EOF && 
!iswprint(c)
                                                       && c != '\n'
                                                       && c != '\t');
                                        if (c == '\n')
@@ -304,7 +312,10 @@
                                }
                                if (attr)
                                        standout();
-                               addch(c);
+                               wchar_t wc = c;
+                               cchar_t cc = {0, {}};
+                               setcchar(&cc, &wc, 0, 0, NULL);
+                               add_wch(&cc);
                                if (attr)
                                        standend();
                        }
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to