@k67/kaitai-struct-ts 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2305,7 +2305,14 @@ var TypeInterpreter = class _TypeInterpreter {
2305
2305
  return this.readFloat(base, endian, stream);
2306
2306
  }
2307
2307
  if (isStringType(type)) {
2308
- throw new ParseError("String types require size, size-eos, or terminator");
2308
+ const encoding = this.schema.meta?.encoding || "UTF-8";
2309
+ if (type === "strz") {
2310
+ return stream.readStrz(encoding, 0, false, true, true);
2311
+ } else if (type === "str") {
2312
+ throw new ParseError(
2313
+ "str type requires size, size-eos, or terminator attribute"
2314
+ );
2315
+ }
2309
2316
  }
2310
2317
  throw new ParseError(`Unknown built-in type: ${type}`);
2311
2318
  }