Stolen from lucene interface on CPAN. \o/
On 27/02/12 16:29, Alberto Simões wrote:
Hello I really need to make my code work with XS and wchar_t. As far as I can tell there is no typemap for that in the core: xs/NATools.c:733: warning: passing argument 3 of ‘Perl_sv_setpv’ from incompatible pointer type I googled for that, and found a typemap, but I do not understand how typemaps work. My typemap looks like: ------ 8< ---------- TYPEMAP wchar_t INPUT T_WCHAR { // Alloc memory for wide char string. This could be a bit more // then necessary. Newz(0, $var, SvLEN($arg), wchar_t); U8* src = (U8*) SvPV_nolen($arg); wchar_t* dst = (wchar_t*) $var; if (SvUTF8($arg)) { // UTF8 to wide char mapping STRLEN len; while (*src) { *dst++ = utf8_to_uvuni(src, &len); src += len; } } else { // char to wide char mapping while (*src) { *dst++ = (wchar_t) *src++; } } *dst = 0; SAVEFREEPV($var); } ------ 8< ------------- But then, this seems to be a Perl => wchar only. I would need the other way around too. Any help? Thanks Ambs