@@ -120,7 +120,10 @@ namespace ts {
120
120
} ;
121
121
122
122
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" ;
124
127
125
128
function getNodeSystem ( ) : System {
126
129
const _fs = require ( "fs" ) ;
@@ -345,7 +348,7 @@ namespace ts {
345
348
function writeFile ( fileName : string , data : string , writeByteOrderMark ?: boolean ) : void {
346
349
// If a BOM is required, emit one
347
350
if ( writeByteOrderMark ) {
348
- data = utf8ByteOrderMark + data ;
351
+ data = byteOrderMarkIndicator + data ;
349
352
}
350
353
351
354
let fd : number ;
@@ -554,7 +557,7 @@ namespace ts {
554
557
writeFile ( path : string , data : string , writeByteOrderMark ?: boolean ) {
555
558
// If a BOM is required, emit one
556
559
if ( writeByteOrderMark ) {
557
- data = utf8ByteOrderMark + data ;
560
+ data = byteOrderMarkIndicator + data ;
558
561
}
559
562
560
563
ChakraHost . writeFile ( path , data ) ;
0 commit comments