Handling Unicode in SMAUG

Posted by Nick Gammon on Tue 10 Feb 2004 03:48 AM — 1 posts, 6,847 views.

Australia Forum Administrator #0
I found when testing my Unicode enhancements to MUSHclient that a heap of things would not work correctly. For instance, typing:


think (some Unicode string)


would result in the MUD replying:


Think what?


A bit of research led to the following lines in function read_from_buffer in comm.c ...


if ( d->inbuf[i] == '\b' && k > 0 )
    --k;
else if ( isascii(d->inbuf[i]) && isprint(d->inbuf[i]) )
    d->incomm[k++] = d->inbuf[i];


This seems to be discarding any input that is not 7-bit ASCII, and is also redundant - why check for "isascii" AND "isprint"?

I suggest this change:


if ( d->inbuf[i] == '\b' && k > 0 )
    --k;
else if (isprint(d->inbuf[i]))
    d->incomm[k++] = d->inbuf[i];


This lets printable characters through, which is what you really want.

After making that change you could "think" or "say" Unicode strings.