Tels <[EMAIL PROTECTED]> writes: >-----BEGIN PGP SIGNED MESSAGE----- > >Moin, > >I have got this XS function: > >void >setWindowCaption(SV* classname, wchar_t* caption) > CODE: > device->setWindowCaption(caption); > >I call it from Perl with: > > $app->setWindowCaption("Some String"); > >Thi does (surprise!) not work properly, because "Some String" is one byte >per char, while I assume that wchar is two bytes.
Why do you assume that? - Windows has wchar_t as 16-bit and is UCS-2 or perhaps UTF-16 - Many modern UNIXes have wchar_t 32-bit and use UCS-4 What system are you on? Which locale / codepage are you in? >How do I convert the perl >string so that it can be passed to the C++ function? > >Is there something which would do this for me easily? L"String" as seen in C >++ does not work in Perl, would some sort of Encode help? If you encode("YourCodePage,"SomeString") then SvPV of the thing should be suitably encoded can can be cast to a wchar_t *