From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu From: Joel Salomon Date: Sun, 4 Feb 2007 21:41:40 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Subject: [9fans] s_putc and Runes Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: 0ce7fc66-ead2-11e9-9d60-3106f5b1d025 I=E2=80=99ve been appending single Runes to Strings, so I checked /n/sources/plan9/sys/src/libString/s_putc.c to see if it handled Runes. Is there a reason it doesn=E2=80=99t, or that s_putrune doesn=E2=80= =99t exist? Here=E2=80=99s my implementation, using none of String internals: void s_putrune(String *s, Rune r) { char rbuf[UTFmax]; s_nappend(s, rbuf, runetochar(rbuf, &r)); } or as part of the library (where I=E2=80=99m a bit shakier on the semanti= cs): void s_putrune(String *s, Rune r) { char rbuf[UTFmax]; int n; if(s->ref > 1) sysfatal("can't s_putc a shared string"); if (s->ptr >=3D s->end - n=3Drunelen(r)) s_grow(s, n+1); (s->ptr) +=3D runetochar(s->ptr, &r); } --Joel