Question

I have problem with showing utf8_general_ci characters. I've set all my tables and columns to utf8 but all non-english alphabet characters dont show (they do but encrypted like this Å¡Äćžđ). Also signs like ' + etc. don't show up. I am running my website on Bluehost.

What is confusing me, is that I use AJAX on my website. When I call AJAX files characters show normaly, but when loaded in non-ajax pages I have an error, I told you about.

Was it helpful?

Solution 2

The reason you don't see the problem with Ajax, is because javascript encoding is UTF-8. This is not the case with PHP, so you should add this to your php.

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

OTHER TIPS

First, you have to know where a charset is used:

  • the data (set with collation/charset in MySQL)
  • the webpage (use your file editor, switch encoding) (in this case the page contents are not relevant I think)
  • the page as your browser requests it (Content-Type: header + <meta>-tag)
  • the MySQL connection (let SET NAMES 'utf8'; be your first query)
  • Under which encoding you put the data into the database: Only put UTF-8 encoded data into your UTF-8 column.

I think that you have wrong encoded data in a correct encoded field, so make sure your data is even UTF-8 before you put it into the database, e.g the page where your form is etc.

Make sure your browser interprets it as UTF-8. Do this with the help of the meta-tags in HTML.

Example:

<head>
    <meta charset="utf-8">
</head>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top