Fwrite encoding issue?


Im grabbing data from an XML feed and using SimpleXMLElement to grab the elements. Im then writing these to another file (using a cron).

This is working fine with the exception of some characters like the ™ ‘Trademark’ symbol.

When I echo the contents of the string before being written it displays fine - but by the time it is written to the static php file the trademark symbol becomes â„¢

Do I need to open the file in a certain way? Currently using this;

echo $header;

		$handle=fopen("header.php","w") or die("cannot open header.php");
		  echo "header updated<br>\

Thanks for the information. I found this article which I found useful. Problem solved.

This is a problem of character sets. Namely the multibyte characters. It’s not encoding anything, it’s just storing what it sees - 3 bytes worth of character data.