Hey gents (again),

I'm having on awful time with decoding UTF16LE character sequences that are
placed into a Nativecall CArray that I've defined as an interface between
Raku and a windows library call.

The structure used by the windows function includes a static wchar_t field
that's PATH_MAX in
length (260 wchar_t's).  It would look like the following in C:

struct Something {
  int32_t dwSize;
  wchar_t a[260];
};

I've written the following as the Raku counterpart to the above:

class Something is repr('CStruct') {
   has int32 $.dwsize;
   HAS int16 @.a[260] is CArray;
};

Given the following definition for the windows library call:

bool Test(Something *x);

.. I've defined the following on the raku side of things:

sub Test(Pointer --> Bool) is native('Kernel32') { * };

----------------------------------------------------------

The function is supposed to write characters into the space allotted,
namely a.
The only required set member prior to calling the subroutine is that the
size of the structure.
It gets set in dwSize like so:

my Something $a .= new(:dwSize(nativesizeof(Something)));

Then the actual function call from the raku side of things:

Test(nativecast(Pointer, $a));

----------------------------------------------------------

All the above is working.  What I'm trying to attempt to do now is display
the contents of that
CArray (raku member a).  In my mind, this is an "array of utf16LE byte
sequences terminated by 0".

What's the cleanest way of doing this in raku?  I've tried variations of
"join" and "encode", simple printf's, say's, etc., and even tried
manipulating this data with Buf's, but I can't seem to get it quite right.

Any help is appreciated.
~Paul
-- 
__________________

:(){ :|:& };:

Reply via email to