I thought wcrtomb did transliteration in glibc; but
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <wchar.h>
#include <assert.h>
main()
{
assert(setlocale(LC_ALL, ""));
char buf[1024];
mbstate_t ps; memset(&ps, 0, sizeof(ps));
int ret = wcrtomb(buf, 0xff41, &ps);
if(ret == -1) perror("wcrtomb");
else {
buf[ret] = 0;
wprintf(L"%s\n", buf);
}
wchar_t xx[2] = { 0xff41, 0 };
wprintf(xx);
wprintf(L"\uff41\n");
wprintf(L"%i\n", wcwidth(0xff41));
}
[EMAIL PROTECTED]/2 [~] ./a.out
a
aa
2
[EMAIL PROTECTED]/2 [~] LANG=C ./a.out
wcrtomb: Invalid or incomplete multibyte or wide character
aa
-1
wprintf is transliterating, wcrtomb isn't. This seems inconsistent,
especially because wcwidth doesn't line up with wprintf.
So, either I'm doing something dumb, or something is being inconsistent.
I wouldn't want to have to switch to iconv or gettext just to get
translit, since they're both a pain for simple apps, but in any case I'd
expect wprintf and wcrtomb to at least do the same thing ...
--
Glenn Maynard
--
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/