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.
UTF-16LE:Unicode character fffe is illegal at C:/perl512/lib/Encode.pm line 174.
$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(
$decodedStr = decode('UTF-16LE', $s, Encode::FB_CROAK);
removing FB_CROAK gave me
$VAR1 = [
"first name string",
"middle name string",
"last name string",
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?