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

Re: sending chinese message to other user using write



(sorry, I forgot to forward to debian-chinese... resending.)

On Sun, Jun 11, 2000 at 07:21:00PM +0800, Wan Hing Wah wrote:
> Hello, this is just a minor problem....
> 	I wanna know if I can send chinese message to other user on the
> same machine using "write",it seem that the write will just display 
> some other letter for some chinese...

  找到原因了。 /usr/bin/write 是非常之非常之非常之非常之不 8-bit clean。
可惡,竟然濾掉所有 8-bit 至 7-bit。想不到現在還有那麼多程式不 8-bit clean。
(竟然用 toascii()……太過份了!)  ^_^  toascii 的 man page 說得是:

       Many  people  will  be  unhappy  if you use this function.
       This function will convert accented  letters  into  random
       characters.

(You guessed it... I am more than unhappy!  grrrrr....)

  Anyhow,我剛寄了個 bug report 給 bsdmainutils 的維護者,希望他
在下一版予以修正。您心急的話,可以自行 "apt-get source bsdmainutils"
(要 potato/woody 裏 version 4.8 那個),
再加以下的 patch,所來個 "make write",就可以了。  ^_^  Thanks for
reporting this problem!  移除中文化路途上的一個絆腳石……

					東東

-- 
Anthony Fok Tung-Ling                Civil and Environmental Engineering
foka@ualberta.ca, foka@debian.org    University of Alberta, Canada
Come visit Our Lady of Victory Camp -- http://www.olvc.ab.ca/

--- write.c~	Wed Jan 19 16:30:57 2000
+++ write.c	Sun Jun 18 09:25:50 2000
@@ -394,19 +394,19 @@
  *     turns \n into \r\n
  */
 wr_fputs(s)
-	register char *s;
+	register unsigned char *s;
 {
-	register char c;
+	register unsigned char c;
 	static int binary_chars = 0;
 
 #define	PUTC(c)	if (putchar(c) == EOF) goto err;
 
 	for (; *s != '\0'; ++s) {
-		c = toascii(*s);
+		c = *s;
 		if (c == '\n') {
 			PUTC('\r');
 			PUTC('\n');
-		} else if (!isprint(c) && !isspace(c) && c != '\007') {
+		} else if (iscntrl(c) && (c != '\007')) {
 			PUTC('^');
 			PUTC(c^0x40);	/* DEL to ?, others to alpha */
 			if (binary_chars ++ > 256) goto binerr;

Reply to: