Skip to content

Commit 46ea4de

Browse files
committed
Revert BOM emit change
1 parent 24fcc3f commit 46ea4de

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/sys.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ namespace ts {
120120
};
121121

122122
export let sys: System = (() => {
123-
const utf8ByteOrderMark = "\u00EF\u00BB\u00BF";
123+
// NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual
124+
// byte order mark from the specified encoding. Using any other byte order mark does
125+
// not actually work.
126+
const byteOrderMarkIndicator = "\uFEFF";
124127

125128
function getNodeSystem(): System {
126129
const _fs = require("fs");
@@ -345,7 +348,7 @@ namespace ts {
345348
function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void {
346349
// If a BOM is required, emit one
347350
if (writeByteOrderMark) {
348-
data = utf8ByteOrderMark + data;
351+
data = byteOrderMarkIndicator + data;
349352
}
350353

351354
let fd: number;
@@ -554,7 +557,7 @@ namespace ts {
554557
writeFile(path: string, data: string, writeByteOrderMark?: boolean) {
555558
// If a BOM is required, emit one
556559
if (writeByteOrderMark) {
557-
data = utf8ByteOrderMark + data;
560+
data = byteOrderMarkIndicator + data;
558561
}
559562

560563
ChakraHost.writeFile(path, data);

0 commit comments

Comments
 (0)