Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Nov 2008 15:54:57 -0800
From:      "Maksim Yevmenkin" <maksim.yevmenkin@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   converting strings from utf8
Message-ID:  <bb4a86c70811041554k6b55854cw711fab508278e398@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70811041554k6b55854cw711fab508278e398>