Add utf-8 support to cols.c

This commit is contained in:
David Parsons
2009-06-17 10:22:50 -07:00
parent 27440b2e2f
commit 8f2ce06098
+8
View File
@@ -19,6 +19,14 @@ char **argv;
for ( xp = 1; (c = getchar()) != EOF; xp++ ) {
if ( c & 0x80 ) {
/* assume that (1) the output device understands utf-8, and
* (2) the only c & 0x80 input is utf-8.
++xp;
do {
putchar(c);
} while ( (c = getchar()) != EOF && (c & 0x80) );
}
if ( c == '\n' )
xp = 0;
if ( xp <= width )