46c46
< __FBSDID("$FreeBSD: head/usr.bin/write/write.c 216370 2010-12-11 08:32:16Z joel $");
---
> __FBSDID("$FreeBSD: head/usr.bin/write/write.c 231586 2012-02-13 14:40:15Z glebius $");
62a63,64
> #include <wchar.h>
> #include <wctype.h>
68c70
< void wr_fputs(unsigned char *s);
---
> void wr_fputs(wchar_t *s);
246c248,249
< char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
---
> char path[MAXPATHLEN], host[MAXHOSTNAMELEN];
> wchar_t line[512];
272c275
< while (fgets(line, sizeof(line), stdin) != NULL)
---
> while (fgetws(line, sizeof(line)/sizeof(wchar_t), stdin) != NULL)
291c294
< wr_fputs(unsigned char *s)
---
> wr_fputs(wchar_t *s)
294c297
< #define PUTC(c) if (putchar(c) == EOF) err(1, NULL);
---
> #define PUTC(c) if (putwchar(c) == WEOF) err(1, NULL);
296,312c299,306
< for (; *s != '\0'; ++s) {
< if (*s == '\n') {
< PUTC('\r');
< } else if (((*s & 0x80) && *s < 0xA0) ||
< /* disable upper controls */
< (!isprint(*s) && !isspace(*s) &&
< *s != '\a' && *s != '\b')
< ) {
< if (*s & 0x80) {
< *s &= ~0x80;
< PUTC('M');
< PUTC('-');
< }
< if (iscntrl(*s)) {
< *s ^= 0x40;
< PUTC('^');
< }
---
> for (; *s != L'\0'; ++s) {
> if (*s == L'\n') {
> PUTC(L'\r');
> PUTC(L'\n');
> } else if (iswprint(*s) || iswspace(*s)) {
> PUTC(*s);
> } else {
> wprintf(L"<0x%X>", *s);
314d307
< PUTC(*s);
< __FBSDID("$FreeBSD: head/usr.bin/write/write.c 216370 2010-12-11 08:32:16Z joel $");
---
> __FBSDID("$FreeBSD: head/usr.bin/write/write.c 231586 2012-02-13 14:40:15Z glebius $");
62a63,64
> #include <wchar.h>
> #include <wctype.h>
68c70
< void wr_fputs(unsigned char *s);
---
> void wr_fputs(wchar_t *s);
246c248,249
< char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
---
> char path[MAXPATHLEN], host[MAXHOSTNAMELEN];
> wchar_t line[512];
272c275
< while (fgets(line, sizeof(line), stdin) != NULL)
---
> while (fgetws(line, sizeof(line)/sizeof(wchar_t), stdin) != NULL)
291c294
< wr_fputs(unsigned char *s)
---
> wr_fputs(wchar_t *s)
294c297
< #define PUTC(c) if (putchar(c) == EOF) err(1, NULL);
---
> #define PUTC(c) if (putwchar(c) == WEOF) err(1, NULL);
296,312c299,306
< for (; *s != '\0'; ++s) {
< if (*s == '\n') {
< PUTC('\r');
< } else if (((*s & 0x80) && *s < 0xA0) ||
< /* disable upper controls */
< (!isprint(*s) && !isspace(*s) &&
< *s != '\a' && *s != '\b')
< ) {
< if (*s & 0x80) {
< *s &= ~0x80;
< PUTC('M');
< PUTC('-');
< }
< if (iscntrl(*s)) {
< *s ^= 0x40;
< PUTC('^');
< }
---
> for (; *s != L'\0'; ++s) {
> if (*s == L'\n') {
> PUTC(L'\r');
> PUTC(L'\n');
> } else if (iswprint(*s) || iswspace(*s)) {
> PUTC(*s);
> } else {
> wprintf(L"<0x%X>", *s);
314d307
< PUTC(*s);