@@ -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" ) ;
@@ -367,7 +370,7 @@ namespace ts {
367370 function writeFile ( fileName : string , data : string , writeByteOrderMark ?: boolean ) : void {
368371 // If a BOM is required, emit one
369372 if ( writeByteOrderMark ) {
370- data = utf8ByteOrderMark + data ;
373+ data = byteOrderMarkIndicator + data ;
371374 }
372375
373376 let fd : number ;
@@ -572,7 +575,7 @@ namespace ts {
572575 writeFile ( path : string , data : string , writeByteOrderMark ?: boolean ) {
573576 // If a BOM is required, emit one
574577 if ( writeByteOrderMark ) {
575- data = utf8ByteOrderMark + data ;
578+ data = byteOrderMarkIndicator + data ;
576579 }
577580
578581 ChakraHost . writeFile ( path , data ) ;
0 commit comments