0

I'm trying to print data from a table that contains a special character such as é. I've used the function htmlentities() hoping it solves the problem, but instead of solving the problem, the data wouldn't appear at all.

For example:

I'm supposed to print this:

"Lightroom 3 pour les Phototographes du Numérique"

However, the character é appears as �. Thus using the fuction htmlentities() should logically solve the problem. Yet whilst using it with a string that contains the character é nothing prints but an empty space. Using the function on a string that contains no special character works fine.

"Lightroom 3 pour les Phototographes du Numerique"

prints as it is, while

"Lightroom 3 pour les Phototographes du Numérique"

prints as

" "

My databse and all the tables are UTF-8 encoded, as well as my html document.

Amine
  • 1,396
  • 4
  • 15
  • 32
  • If you are using UTF-8 everywhere then **you don't need HTML entities** to display accented characters. You're most likely failing to use/declare UTF-8 properly somewhere in your flow. – Álvaro González Oct 03 '16 at 09:11

1 Answers1

1

When you read htmlentities documentation, it says that

If the input string contains an invalid code unit sequence within the given encoding an empty string will be returned, unless either the ENT_IGNORE or ENT_SUBSTITUTE flags are set.

As suggested in the doc, you can try to force the encoding (maybe "ISO-8859-1" or "ISO-8859-15")?

Ayak973
  • 468
  • 1
  • 6
  • 23
  • Using ISO-8859-1 works well in my case. – Amine Oct 03 '16 at 18:50
  • Glad to see it resolve your issue, but as @Álvaro González suggested, **'you don't need HTML entities'**, you have to check [UTF8 How to](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) to see where in your files, **'you fail to use/decalre UTF8 properly'** – Ayak973 Oct 04 '16 at 06:50
  • If using `ISO-8859-1` fixes the problem then the base information "My databse and all the tables are UTF-8 encoded, as well as my html document" happens to be false. – Álvaro González Oct 04 '16 at 08:21