dm2-graphics: dtText should truncate at first NUL like the engine — JP ports pad to even length, crate emits trailing U+0000 #193
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Text::parse(crates/dm2-graphics/src/text.rs~145) requires the last decoded byte to be NUL and tokenises everything before it. The engine stops at the first NUL:DM2_FORMAT_SKSTRterminates on'\0'wherever it appears ([SKPROJECT] v5/gfxstr.cpp:326-331).This diverges on real data: 384 Mac JP and 382 FM-Towns Japanese dtText payloads decode to
…text\0\0— the string is NUL-terminated one byte early and padded to even length. The crate keeps the interior NUL as a literal byte, so:segments()carries a spurious trailing0x00in the lastLiteral;to_display_string()on those records ends with U+0000 (encoding_rs maps CP9320x00→ NUL).Probed: every affected payload has exactly one padding byte and it is always zero (no port hides content after the first NUL), so truncation is safe. dos-en / mac-us / amiga / sega-cd have no interior NULs at all.
Fix direction
Truncate the decoded body at the first NUL (and keep
MissingNulfor payloads with none anywhere), matching the engine. The even-length padding convention is worth a line indocs/formats/graphics-dat.md§ dtText.Probe:
scratch/probe_text_nul.py(gitignored).Fixed by #208 (merged into
main).