man asprintf
это char, a wchar_t внизу.
я задумал получилось.
#include "z.h"
#include <stdarg.h>
#include <locale.h>
int aswprintf (wchar_t **wc, const wchar_t *wfmt,...){
FILE *fnl =
fopen ("/dev/null","w");
va_list ap;
va_start ( ap, wfmt );
int l = vfwprintf (fnl,wfmt,ap);
va_end ( ap );
*wc = malloc (sizeof (wchar_t)*(l+1));
fclose (fnl);
va_start ( ap, wfmt );
l = vswprintf (*wc,l+1,wfmt,ap);
va_end ( ap );
return l;
}
int main (){
setlocale (LC_ALL,getenv("LANG"));
wchar_t *wc;
int l = aswprintf (&wc,L"%hs %ls","A",L"я был.");
printf ("%d. %ls\n",l,wc);
free (wc);
return 0;
}
вывод
8. A я был.