Minivera / FocusTreeAndEventManager

Focus tree and Event manager for Heart of Iron IV
36 stars 29 forks source link

Localization Bug (Byte Order Mark) #25

Open Chupachu opened 6 years ago

Chupachu commented 6 years ago

I've recently found an issue that the program does not compile the localization files in UTF8-BOM, but rather UTF8, which the game is unable to use for localization. Recently, I developed a Country Generator, which requires BOM in order to get the localization to work, so if you're interested in the way I did this, I have a sample of code below that properly enables Byte Order Mark and should be compatible with your program.

Here is a solution I found for writing files with Byte Order Mark enabled:

        Stream s = File.Open(""+OFD_Loc.FileName,FileMode.Open);

        using (var sw = new StreamWriter(s, new UTF8Encoding(true)))

        {

            sw.WriteLine(lines);

        }

I hope this helps.

Minivera commented 6 years ago

Could you make a pull request for this solution?

While I do not have the time to make further fixes for now, I could still release a hotfix with this solution on the PDX forums.

Chupachu commented 6 years ago

@Minivera I was unable to make a pull request due to my lack of experience with GitHub and my lack of authorization to publish a branch, but in Project.cs on line 77, replace 'using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding()))' with 'using (TextWriter tw = new StreamWriter(stream, new UTF8Encoding(true)))' to fix the files and make them be exported in BOM. Sorry if this is inconvenient, I tried a pull request and also tested to make sure no errors were created. o