-1

I'm trying to load html from a MySQL database and display it via my php script. But it won't display foreign characters correctly.

I've already changed php.ini to have the default charset as utf-8 and I've set my php header to:

header('Content-Type: text/html; charset=utf-8');

And it still won't display the characters correctly. It's starting to really annoy me because I've tried every solution and none of them seem to be working.

ThePerplexedOne
  • 2,920
  • 15
  • 30

2 Answers2

0

Try to set charset on mysql query

$mysqli->set_charset("utf8")
Andrei Todorut
  • 4,260
  • 2
  • 17
  • 28
-1

Nevermind, I just needed to add:

utf8_decode($html);

to the end of my script... god damnit.

ThePerplexedOne
  • 2,920
  • 15
  • 30
  • That's a terrible fix. `utf8_decode` does an encoding conversion. To keep your sanity, you never want to have to do any encoding conversion whatsoever. See [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/). – deceze Jun 10 '16 at 09:18