I have the e acute character (é) in a file which gets read and split up for various parts of a PHP script. I noticed that the 'é' is getting converted into a 'Z' with a '~' over it. So I figured I'd have to run the string through the htmlentities() function hoping to turn 'é' into 'é' but that didn't work. 🙁
I'm using this code to read the file:
$filename = 'file.php';
$fd = fopen($filename, "r") or die("couldn't open file");
// read the contents of the file
$fstring = fread($fd, filesize($filename));
fclose($fd);
// make the new lines all consistently \n
$fstring = str_replace("\r", "\n", $fstring);
$fstring = str_replace("\n\n", "\n", $fstring);
// create an array containing each line
$lines = explode("\n", $fstring);
I "echoed" the $fstring to the browser before anything happens to it and sure enough, the é character isn't getting read in properly, and thus isn't reaching the htmlentities() function. Is there something I have to do to get the file to be read so that accented letters like this get read properly?
Any ideas?