I have an interesting file format to decode. Its based off C structs, but with tons of null terminated strings, UTF16LE strings are mixed with ASCII strings, all null terminated. The string lengths are variable, but there is always the same number and position of strings and longs in the same pattern (struct-ish). A sample of what the record looks like is below and my attempts to far to decode it.
$s = encode('UTF-16LE', "first name string\0").encode('UTF-16LE', "mi
+ddle name string\0").
encode('UTF-16LE', "last name string\0").pack('V', 3654877182).pack('V
+', 1).encode('UTF-16LE', "address string\0")."zip code ascii\0".pack(
+'V',1);
$decodedStr = decode('UTF-16LE', $s, Encode::FB_CROAK);
print Dumper([unpack('Z*Z*Z*VVZ*Z*V',$decodedStr)]);
UTF-16LE:Unicode character fffe is illegal at C:/perl512/lib/Encode.pm line 174.
removing FB_CROAK gave me
$VAR1 = [
"first name string",
"middle name string",
"last name string",
"1627454973",
"1701995620",
"ss string",
"\x{697a}\x{2070}\x{6f63}\x{6564}\x{6120}\x{6373}\x{6969}\x{
+100}"
];
and warning, "Character(s) in 'V' format wrapped in unpack"
Is there any way to use pack to decode this, or any other template style way of decoding this without writing a byte level parser using substr and index and a current character position integer?
as far as I understand, pack doesn't understand what a null terminated UTF16 string is, right?