converting strings from utf8

Maksim Yevmenkin maksim.yevmenkin at gmail.com
Tue Nov 4 16:19:31 PST 2008


Hello,

can i use wcstombs(3) to convert a string presented in utf8 into
current locale? basically i'm looking for something like iconv from
ports but included into base system.

in other words, would something like this work?

char *locale, dst[256];
size_t len;

locale = setlocale(LC_CTYPE, "");
if (locale == NULL)
  /* bail */

len = wcstombs(dst, (wchar_t *) src, sizeof(dst));
if (len < 0)
  /* bail */

printf("%*.*s\n", len, len, dst);

thanks,
max


More information about the freebsd-hackers mailing list