I have been working on a PHP program that at the end exports an HTML file. I am encountering an issue where sometimes French characters are not properly written to the file (it is not an issue with the webpage, I opened the file in notepad and the characters were just changed).
Here is the piece of code that I have written:
foreach($footer as $a){
echo $a;
fwrite($file, $a."\r\n");
}
The echo displays the following:
En cas de divergence entre le présent document et les documents contractuels officiels, ces derniers ont préséance.
But what is written to the file is:
En cas de divergence entre le présent document et les documents contractuels officiels, ces derniers ont préséance.
A couple lines above this in my code I export lines with other French characters and they work just fine (it is essentially exactly the same code), but here it is not.
I have tried using fputs(), changing fopen($file,'w') to fopen($file, 'wb'), adding utf_encode() (which just makes the mess that comes out look worse), etc. and nothing has fixed this issue. Any ideas?