I'm new to XS, so excuse my basic question

I have a C function that received a pointer to string. The string is scanned 
and each charater code is placed in a INPUT struct.

void send_string (const wchar_t * str) {
                 printf("send_string : %s L:%i\n", str, wcslen(str));
         ...
                for (p=str ; *p; p++) {
                               ...
                               inp[0].ki.wScan = inp[1].ki.wScan = *p;
                               printf("wScan has %i\n", *p);
                               SendInput(2, inp, sizeof(INPUT));

                }

}

My xs file for this is just

TYPEMAP: <<HERE
const wchar_t * T_WCHAR
INPUT
T_WCHAR
    $var = ($type)SvPV_nolen($arg)
OUTPUT
T_WCHAR
    sv_setpv((SV*)$arg, $var);
HERE

void
send_string(s)
     const wchar_t * s


When I test this send_string function, I see that
                printf("%s", str) is correct
                the value return by wcslen(str) is not constant and is too 
large, it's herratic and varied from the same string value sent from perl
                the values in wScan are wrong except for the first character

The INPUT and OUTPUT part of the typemap are copied from T_PV.

I have tried more elaborate conversion taken from this thread
http://grokbase.com/t/perl/xs/06bxe1krvk/t-wchar-final
but the code does not  compile.

Thanks for any help.

François

Reply via email to