encoding is ignored in fs.readFile

后端 未结 2 592
日久生厌
日久生厌 2021-02-07 01:47

I am trying to read the contents of a properties file in node. this is my call:

fs.readFile(\"server/config.properties\", {encoding: \'utf8\'}, function(err, dat         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-07 02:13

    You should change {encoding: 'utf8'} to {encoding: 'utf-8'}, for example:

    fs.readFile("server/config.properties", {encoding: 'utf-8'}, function(err, data ) {
    console.log( data );
    });
    

提交回复
热议问题