NeighTools / UnityDoorstop

Doorstop -- run C# before Unity does!
GNU Lesser General Public License v2.1
419 stars 62 forks source link

UnityDoorstop doesn't load when doorstop_config.ini is written in UTF-8 with BOM #13

Closed sebastienvercammen closed 3 years ago

sebastienvercammen commented 3 years ago

Hi there,

Using C# targeting .NET 4.0 and 4.5 (tested separately), I used File.WriteAllText to write changes to my doorstop_config.ini.

With the following code, this writes as UTF-8 with BOM:

File.WriteAllText(path, contents, Encoding.UTF8);

And this broke UnityDoorstop. It just wouldn't load.

Changing the file write to UTF-8 without BOM (explicit) fixed it:

File.WriteAllText(path, contents, new UTF8Encoding(false));
ghorsington commented 3 years ago

Doorstop makes use of WinAPI's GetPrivateProfileStringW to read its INI file and thus how the configs are read depend on that.

There is no intention on changing the API or implementing one as the one provided by Windows works fine for the purposes of Doorstop. As such, I'm marking this as a wontfix and closing this issue.

I've updated the wiki page to note that the config file must not have a byte order mark.