// get function argument char* NodeName = (char *)SvPV(ST(0),PL_na); // get argument length int nNodeNameLen = strlen(NodeName) + 1; // alloc memory LPWSTR wNodeName = (LPWSTR)malloc(nNodeNameLen * sizeof(WCHAR)); // do conversion mbstowcs(wNodeName, NodeName, nNodeNameLen); // Here's where I'd actually use the data // I'm leaving out the part where I allocate widebuffer someLibFunction(wNodeName, widebuffer, buffersize); // de-allocate free(wNodeName); /* And now I'd have to do it all in reverse: allocate a new char* buffer, convert the output back to char*, deallocate the wide buffer, put the result back on the stack, and free the wide buffer. */