From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 3 May 2007 18:55:49 -0400 From: Kris Maglione To: 9fans@cse.psu.edu Subject: Re: [9fans] Mac p9p snarf buffer Message-ID: <20070503225549.GA62050@kris.home> References: <485433e531411cebe17458a6a0b7b515@9netics.com> <7359f0490705030945y5c58866akd5b0e37620416cfd@mail.gmail.com> <3e1162e60705031045u54008defy568624cdc99de310@mail.gmail.com> <7359f0490705031052x3a2d8155x1cab9d4dafa405d4@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" Content-Disposition: inline In-Reply-To: <7359f0490705031052x3a2d8155x1cab9d4dafa405d4@mail.gmail.com> User-Agent: Mutt/1.5.15 (2007-04-06) Topicbox-Message-UUID: 57b205ca-ead2-11e9-9d60-3106f5b1d025 --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 03, 2007 at 10:52:26AM -0700, Rob Pike wrote: > The snarf issue that bothers me most these days is that the > plan9port programs, at least on the mac, don't handle UTF-8 > in the snarf buffer correctly. UTF-8 going out turns into junk; > going in it turns into question marks. Yes, this bothered the hell out of me, too. I fixed my copy of=20 devdraw(1) to ask for a UTF8_STRING before a STRING, as suggested by the=20 comment, which seems to imply that the extra polling is not worth the=20 effort: * We should try to go for _x.utf8string instead of XA_STRING, * but that would add to the polling. I hacked this together in about a minute, so it's not beautiful, but it=20 works. $PLAN9/src/cmd/devdraw/x11-itrans.c:439: prop =3D 1; data =3D nil; XChangeProperty(_x.display, _x.drawable, prop, _x.utf8string, 8, PropModeR= eplace, (uchar*)"", 0); XConvertSelection(_x.display, clipboard, _x.utf8string, prop, _x.drawable,= CurrentTime); XFlush(_x.display); lastlen =3D 0; for(i=3D0; i<10 || (lastlen!=3D0 && i<30); i++){ usleep(100*1000); XGetWindowProperty(_x.display, _x.drawable, prop, 0, 0, 0, AnyPropertyTyp= e, &type, &fmt, &dummy, &len, &data); if(lastlen =3D=3D len && len > 0) break; lastlen =3D len; } if(lastlen =3D=3D 0) { XChangeProperty(_x.display, _x.drawable, prop, XA_STRING, 8, PropModeRepl= ace, (uchar*)"", 0); XConvertSelection(_x.display, clipboard, XA_STRING, prop, _x.drawable, Cu= rrentTime); XFlush(_x.display); lastlen =3D 0; for(i=3D0; i<10 || (lastlen!=3D0 && i<30); i++){ usleep(100*1000); XGetWindowProperty(_x.display, _x.drawable, prop, 0, 0, 0, AnyPropertyTy= pe, &type, &fmt, &dummy, &len, &data); if(lastlen =3D=3D len && len > 0) break; lastlen =3D len; } } if(lastlen =3D=3D 0) goto out; --=20 Kris Maglione --ibTvN161/egqYuK8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.3 (FreeBSD) iD8DBQFGOmh1seQZD8Aui4wRAu3CAJoCxfgKlmZSQOidjmwzzlKuQwDxuwCeOfTJ tkAAH9ywaPukqsoi5MuujoM= =r4ot -----END PGP SIGNATURE----- --ibTvN161/egqYuK8--