1

I've looked at all the relevant topics on the site and this particular gotcha does not seem to be covered

I exported a Word 2016 document (in French) as filtered HTML ( filtered= no office specific stuff included). If I show the file in my browser as html, everything is fine - all the accents show correctly. ( Charset is utf-8 and it's not coming from a database). But when I change the extension to .php and run it, all the french characters are shown as black diamonds with a question mark inside.

If I express the french characters as html entities, they show correctly, but I don't want to do this as the fix - there are hundreds of them in there, and I don't want to edit the text - it's not mine and the author would have to proof read it all again just to check the accents.

So I figured it's a PHP (5.5.26) issue - but I can't see anything in the ini file which might affect this - it looks like UTF-8 is the default charset if you don't change anything,

What's the fix ??

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
sackbut
  • 19
  • 1
  • 2

1 Answers1

0

If this is a problem with just one file, you can use the following:

<?php
header('Content-Type: text/html; charset=iso-8859-1');
?>

On the html part add or change:

<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1 />

If you've thousands of files and you don't want to change them manually you can try to modify the following line on your php.ini:

default_charset = "utf-8"

to

default_charset = "iso-8859-1";

Save and restart the server.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268