Alexander E. Patrakov пишет:
Pasha Zubkov wrote:
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.x
Hello, this patch fix UTF-8 issue with `watch` at least in ru_RU.UTF-8
and be_BY.UTF-8.
Rejected, breaks ru_RU.KOI8-R.
Added test for 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 18:53:43.000000000 +0200
@@ -25,6 +25,8 @@
#include <termios.h>
#include <locale.h>
#include "proc/procps.h"
+#include <wctype.h>
+#include <langinfo.h>
#ifdef FORCE_8BIT
#undef isprint
@@ -144,8 +146,10 @@
float interval = 2;
char *command;
int command_length = 0; /* not including final \0 */
+ int utf8_mode;
setlocale(LC_ALL, "");
+ utf8_mode = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
progname = argv[0];
while ((optc = getopt_long(argc, argv, "+d::hn:vt", longopts, (int *)
0))
@@ -274,9 +278,19 @@
/* 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 (utf8_mode) {
+ 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 && (utf8_mode
? !iswprint(c) : !isprint(c))
&& c != '\n'
&& c != '\t');
if (c == '\n')
@@ -304,7 +318,14 @@
}
if (attr)
standout();
+ if (utf8_mode) {
+ wchar_t wc = c;
+ cchar_t cc = {0, {}};
+ setcchar(&cc, &wc, 0, 0, NULL);
+ add_wch(&cc);
+ } else {
addch(c);
+ }
if (attr)
standend();
}
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page