in reply to import UTF-16 strings in XS

my $utf8= pack "U*", unpack "S*", $utf16; $utf8 =~ s/\0.*//s;

provided that you return the UTF-16 string properly to Perl.

Details about memory allocation complicate exactly how to do this (especially since Perl refuses to deal with memory that it didn't allocate itself). So I can't give much more detail without guessing, so I'll leave it at that for now.

Oh, and Win32API::Registry knows how to return such strings to Perl "properly" for some APIs; in case some sample code would be useful. Note that I wrapped up this stuff in some macros that I reuse several places.

- tye