0

I have a page that I'm saving that I noticed is converting special characters in the html to their entities when its saved and then viewed. I have been trying to use htmlentities_decode and other options but cannot seem to figure out how to get it to NOT change any special characters on saving.

an example of the html looks like this:

•Los Angeles•</font></b><br><font color="#ABABAB" size="-1">°Airport°

and when saved it comes out looking like this:

•Los Angeles•
°Airport°

A portion of My save code where I'm sure I'm missing the command is:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$data = $_POST['edit'];
if(get_magic_quotes_gpc()){
$data = stripslashes($data);}
$filevar = "/my/site/address/here/creative/lacrimes/actions";
$fp = fopen($filevar, "w") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!"); 
user3518979
  • 77
  • 2
  • 7
  • 3
    Those are __not__ entities – but UTF-8 character sequences interpreted in/as a different character encoding. – CBroe May 11 '14 at 23:08
  • That definitely helps in explaining the difference and that I was looking at it wrong, thank you CBroe. Would simply specifying the encoding as its saved preserve the characters? – user3518979 May 11 '14 at 23:10
  • You need to add a BOM/byte-order-mark or change your php settings. Here's how to add the [BOM](http://stackoverflow.com/a/12215021/963011). – Ally May 11 '14 at 23:12

0 Answers0