Skip to content

Commit 26ef7e5

Browse files
authored
Merge pull request microsoft#19991 from Microsoft/fix-bom
Use UTF8 BOM in emit
2 parents 5d5da4c + 2f941f3 commit 26ef7e5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/compiler/sys.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ namespace ts {
125125
};
126126

127127
export let sys: System = (() => {
128+
const utf8ByteOrderMark = "\u00EF\u00BB\u00BF";
129+
128130
function getNodeSystem(): System {
129131
const _fs = require("fs");
130132
const _path = require("path");
@@ -348,7 +350,7 @@ namespace ts {
348350
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
349351
// If a BOM is required, emit one
350352
if (writeByteOrderMark) {
351-
data = "\uFEFF" + data;
353+
data = utf8ByteOrderMark + data;
352354
}
353355

354356
let fd: number;
@@ -549,7 +551,7 @@ namespace ts {
549551
writeFile(path: string, data: string, writeByteOrderMark?: boolean) {
550552
// If a BOM is required, emit one
551553
if (writeByteOrderMark) {
552-
data = "\uFEFF" + data;
554+
data = utf8ByteOrderMark + data;
553555
}
554556

555557
ChakraHost.writeFile(path, data);

0 commit comments

Comments
 (0)