I had previously set the locale with setlocale(LC_ALL, ""); I reset the locale to the C before trying to write to a file but opening the file it puts it in binary mode. I suspect this is due to wrong encoding.
setlocale(LC_ALL, "C");
FILE *file = fopen("actions.txt", "w");
for(int i = 0; i < arrlen(game.action_history); ++i) {
struct Action *action = &game.action_history[i];
char buffer[32];
char color = PIECE_COLORS[action->piece];
char species = LETTER[PIECE_SPECIES[action->piece]];
int number = PIECE_NUMBERS[action->piece];
snprintf(buffer, 32,
"%c%c%d %d %d %d %d %d %d\n",
color, species, number,
action->source.q, action->source.r, action->source.s,
action->destination.q, action->destination.r, action->destination.s);
fwrite(buffer, 32, 1, file);
}
fclose(file);