From f338a43ff25b607a1910ef3e4225de4cc9d0f9f8 Mon Sep 17 00:00:00 2001 From: Dustinspace217 Date: Sat, 17 Oct 2026 01:35:25 -0700 Subject: [PATCH] Skip a UTF-8 byte order mark at the start of fs2_open.ini profile_read did not recognize a section header preceded by a byte order mark, so every key under the first section ([Default]) was dropped. The next settings save wrote the file back without them. Editors such as Notepad can save the file with a mark. --- code/osapi/osregistry.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/osapi/osregistry.cpp b/code/osapi/osregistry.cpp index b45018e2395..5e941188258 100644 --- a/code/osapi/osregistry.cpp +++ b/code/osapi/osregistry.cpp @@ -621,8 +621,15 @@ static Profile *profile_read(const char *file) IniSection *sp = nullptr; KeyValue **kvp_ptr = nullptr; + bool first_line = true; while ((str = read_line_from_file(fp)) != nullptr) { + // some editors save a UTF-8 byte order mark, which would hide the first section header + if (first_line && !strncmp(str, "\xEF\xBB\xBF", 3)) { + memmove(str, str + 3, strlen(str + 3) + 1); + } + first_line = false; + char *ptr = trim_string(str); if (*ptr == '[') {