1

Could someone help me on how to fix this bad encoding?

The right output would be Église (this is what I have in the DB), however I'm getting Église in the html output.

After running mb_detect_encoding(), I get "UTF-8". I've tried utf8_decode() without success, so I'm kind of lost and would need some guidance. Thanks all!

gs-rp
  • 377
  • 1
  • 3
  • 16

2 Answers2

2

This is almost definitely an issue with the charset. If you're using Apache you can force charset utf-8 in your .htaccess:

AddDefaultCharset utf-8

Alternatively, you can also set the charset in PHP

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

Note that header() must come before any output.

Tim
  • 2,123
  • 4
  • 27
  • 44
0

You need to add a meta tag with the charset attribute in your HTML document to encode your web page. Add the following meta tag in your head section.

<meta charset='utf-8'>

Hope it should work.

Wolverine
  • 1,712
  • 1
  • 15
  • 18
  • It's set already, I forgot to mention it's an ajax call and the results will be displayed in a new drop down. Thanks anyway. – gs-rp Aug 18 '16 at 16:45
  • You mean the data from ajax response will be populated in a drop down control and the encoding in it doesn't work? – Wolverine Aug 18 '16 at 16:49
  • exactly. It's weird. – gs-rp Aug 18 '16 at 17:36
  • If you're using jQuery for ajax operation, you need to specify contentType property in $.ajax like $.ajax({url: 'page.php', contentType: 'application/json; charset=utf-8'}); – Wolverine Aug 18 '16 at 18:00