Browse Source

Compiling through a Batch file should not produce a BOM.

David Piuva 1 year ago
parent
commit
c4b0d3fee9
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Source/tools/builder/code/generator.cpp

+ 2 - 1
Source/tools/builder/code/generator.cpp

@@ -217,7 +217,8 @@ void produce(SessionContext &input, const ReadableString &scriptPath, ScriptLang
 	if (GENERATE) {
 	if (GENERATE) {
 		printText(U"Saving script to ", scriptPath, "\n");
 		printText(U"Saving script to ", scriptPath, "\n");
 		if (language == ScriptLanguage::Batch) {
 		if (language == ScriptLanguage::Batch) {
-			string_save(scriptPath, generatedCode);
+			// Batch on MS-Windows can not recognize a Byte Order Mark, so just encode it as Latin 1.
+			string_save(scriptPath, generatedCode, CharacterEncoding::Raw_Latin1, LineEncoding::CrLf);
 		} else if (language == ScriptLanguage::Bash) {
 		} else if (language == ScriptLanguage::Bash) {
 			string_save(scriptPath, generatedCode, CharacterEncoding::BOM_UTF8, LineEncoding::Lf);
 			string_save(scriptPath, generatedCode, CharacterEncoding::BOM_UTF8, LineEncoding::Lf);
 		}
 		}