Skip to content

Commit 4a460f1

Browse files
committed
Fixing issue preserving script encoding
1 parent 67fb32f commit 4a460f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/WebJobs.Script/Description/DotNet/CSharp/CSharpCompilationService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ private static string GetFunctionSource(FunctionMetadata functionMetadata)
6363

6464
if (File.Exists(functionMetadata.ScriptFile))
6565
{
66-
code = File.ReadAllText(functionMetadata.ScriptFile);
66+
// We use ReadAllBytes here to make sure we preserve the BOM, if present.
67+
var codeBytes = File.ReadAllBytes(functionMetadata.ScriptFile);
68+
code = Encoding.UTF8.GetString(codeBytes);
6769
}
6870

69-
return Utility.RemoveUtf8ByteOrderMark(code ?? string.Empty);
71+
return code ?? string.Empty;
7072
}
7173

7274
private Compilation GetScriptCompilation(Script<object> script, FunctionMetadata functionMetadata)

0 commit comments

Comments
 (0)