From 46ea4de7bcd11a5b8e620e6a5002ca99fc461fa9 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 12 Feb 2018 12:02:34 -0800 Subject: [PATCH] Revert BOM emit change --- src/compiler/sys.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3256eef4dc2..1e092f8c579 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -120,7 +120,10 @@ namespace ts { }; export let sys: System = (() => { - const utf8ByteOrderMark = "\u00EF\u00BB\u00BF"; + // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual + // byte order mark from the specified encoding. Using any other byte order mark does + // not actually work. + const byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem(): System { const _fs = require("fs"); @@ -345,7 +348,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = utf8ByteOrderMark + data; + data = byteOrderMarkIndicator + data; } let fd: number; @@ -554,7 +557,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = utf8ByteOrderMark + data; + data = byteOrderMarkIndicator + data; } ChakraHost.writeFile(path, data);