Quick answer: GameMaker buffer_read with buffer_string stopping at the first null byte? C-string semantics - use buffer_read with buffer_u8 in a loop or use buffer_text for the full content.

Save file with binary data after a string. Reading the string truncates at the embedded null.

Use buffer_text

Reads until end-of-buffer regardless of nulls. Right primitive for embedded-null payloads.

Or length-prefix manually

var len = buffer_read(buf, buffer_u32);
var str = "";
repeat len { str += chr(buffer_read(buf, buffer_u8)); }

Manual loop; respects the length you wrote.

Avoid buffer_string for binary

buffer_string is for C-strings. Binary protocols need buffer_text or length-prefixed.

“buffer_string is a C-string. C-strings stop at nulls.”

For mixed text/binary save formats, define the spec carefully. Use buffer_text for text fields; length-prefix everything else.

Related reading