Hi—
I manage a small community server which hosts a local chat program originally written by one of our users about 13 years ago. The last significant update was December of 2001. I am now wading through the code trying to adapt it to handle utf8 locales (and cleaning up other obsolescences in the process). In the process, I hope to allow extended typographical characters, too.
I am stuck on the isalnum() function. Globalyzer says ANSI does not provide an ismbalnum(), so one must convert a multibyte character to wide using mbtowc() and then use iswalnum():
Code:
#include <stdlib.h>
int mbtowc( wchar_t *pwc, const char *s, size_t n );
int iswalnum(wint_t c);
n is, I think, MB_CUR_MAX, defined in stdlib.h. It looks like, for a line of original code like this:
Code:
if (isalnum(testchar) {
I should instead have something more like:
Code:
wchar_t widetestchar;
if (!mbtowc(widetestchar, testchar, MB_CUR_MAX)) exit(1);
if (iswalnum(widetestchar)) {
Am I on the right track here? The last time I was programming regularly this sort of thing wasn't really on the radar.
Thanks—
q.
(o, and I'm aware that there are plenty of modern chat programs already written that I could install instead. That won't fly here.)