Reinhard Pagitsch <[EMAIL PROTECTED]> writes: >Hello, > >I have an other problem: I pass a file name to my XS code which have to >be of type wchar_t *. >I tryed it in the .XS as follow >int >properties::ReadProperty(File); > wchar_t * File
We would need to see what that expands to. But the _default_ typemap for wchar_t just passes the raw perl string. For that to work you would need to have encode()ed the string to your wchar_t's representation. On Unix in general what wchar_t is varies widely. There is though a slight trend to move to 32-bit wchar_t and UCS-4 as the representation (endian being dependant on processor). On windows wchar_t is 16-bit and started life as UCS-2le (i.e. just bottom 16 bits of Unicode space), I have heard that now it is considered to be UTF-16le. > > >But allways I get from StgIsStorageFile() the error message >STG_E_FILENOTFOUND. >If I use the filename hard coded wchar_t * m_File = >L"d:\\test\\test.doc"; then it works. >How do I pass the filename correctly to my function? Something like (untested): use Encode; ReadProperty(encode('UTF-16LE',$string)); There is a possible snag if encode trys to prepend a byte-order-mark (BOM). > >I also tryed >int >properties::ReadProperty(File); > char * File >and used MultiByteToWideChar using OEM code page to convert the char * >to wchar_t *, but had no success. That is not going to work unless you have encoded the file name to OEM code page before calling your XS function, or it started life in that form and you haven't done any encode or Unicode operations on it. Perls strings which have been processed can be in one of two forms: - default (single) byte encoding is "iso-8859-1" (sometimes) - UTF-8 You could call SvPV_utf8() on the passed in SV to get it into latter form ant then call MultiByteToWideChar() using the UTF-8 "code page" if MS has one. > >Thank you, >Reinhard