kylex
kylex

Reputation: 14406

UTF-8 encoding issues with database and displaying on webpage

I have the following character ó stored in a VARCHAR column on a MySQL database. The collation for this column is utf8_general_ci

On the webpage I have the following meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Yet when the data is pulled out and displayed it show as: �

But ONLY on my Mac.

If I had mysql_query("SET NAMES 'UTF8'"); then it displays properly on my Mac.

On my PC it displays properly, but when I add mysql_query("SET NAMES 'UTF8'"); it displays incorrectly.

What am I missing?

Upvotes: 0

Views: 930

Answers (1)

Anders Lindahl
Anders Lindahl

Reputation: 42870

There are lots of things that could be causing this, and the web browsers you have tried might try to be helpful in different ways or have different defaults.

Judging from MySQL manual 9.1.10. Unicode Support, SET NAMES 'UTF8' should be used if you want UTF-8 output from MySQL.

Your content-type looks a bit strange, is it a typo? It should probably be:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I'd start by using a network sniffer (for example TCPView or Wireshark) or some other means to verify that the output from the server really is UTF-8, i.e. that the ó is sent from the server as 0xC3 0xB3. If that is ok, check for problems with Content-type settings.

Upvotes: 1

Related Questions