Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 602 forks source link

Problem encoding french accents #506

Open faouzi-Lakhlifi opened 5 years ago

faouzi-Lakhlifi commented 5 years ago

I read xml from a (~45mb) file then parse it then write it to another, works fine except for some characters mainly french accents, that turn into �; here's my code;


parser.parseString(fs.readFileSync('./files/file.xml','utf8'), function(err,result){
    result["objectName1"]["objectName2"].Message.forEach(msg =>{
          msg.content.objectName3.forEach(OCT => {
            OCT.stuff.forEach(ord => {
                ord[Object.keys(ord)[0]].forEach((O) => {
                        lstobjects.push(O[Object.keys(O)[1]][0])
                })
            })
        })
    })
    fs.writeFile('./files/object.txt',JSON.stringify(lstobjects),function(err,res){
        if(err) console.log(err);
        console.log("Done")
    })
 })
suguoyao commented 2 months ago

same issue..