1

This issue is mind-boggling to me. I am facing the following situation. I wrote a website in html using the utf8 charset. Special characters are displayed as expected. Now I want to give out some php mysql results, so the easiest way is to create a php file, include the html code and then give out the results. However the html given out via the php file does not display the special characters correctly... it's not utf8

here is the html version: HTML

and here the exact copy in a php file: HTML VIA PHP

CMX
  • 33
  • 6
  • 3
    http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Marc B Nov 20 '14 at 14:30
  • header('Content-type: text/html'); in php is set. no effect. – CMX Nov 20 '14 at 14:52
  • that's a **TYPE**. It does NOTHING for the charset. If you don't tell the client what charset you build your output in, it's free to choose whatever charset it wants. `Content-type: text/html; charset=utf8` – Marc B Nov 20 '14 at 14:54
  • Forgive me, I didn't copy the entire code, the header code is as follows: `header('Content-Type: text/html; charset=utf-8');` But still it is not utf8 and the meta tag in the html code is set to utf8 too – CMX Nov 20 '14 at 14:58
  • then did you maintain utf throughout the **ENTIRE** pipeline? `client->php->db connection->db tables->db connection->php->client`. A charset mismatch **ANYWHERE** in the chain will trash your text. – Marc B Nov 20 '14 at 15:00
  • Yes I did, I checked everything your first comment mentioned and still the text is messed up – CMX Nov 21 '14 at 09:37

1 Answers1

0

To close this question myself (because I feel rather stupid right now), the one who actually solved this is Marc B as his comments made me understand the process of text encoding.

After setting the header (Content Type and charset) as well as setting the meta tag in HTML I discovered, just like Marc suspected that my IDE had encoded the php file in another encoding than UTF8. Saving the file as UTF8 and replacing the messed up specialchars fixed my issue.

Please excuse this, I wasn't fully aware of what I was doing.

CMX
  • 33
  • 6