My website is showing the wrong characters as you can see in the attached image, taken from google analytics:
Now, the problem is that these characters only show SOMETIMES, which I find very strange.
I've tried changing the database collation to utf-8 as per this post.
And I've also tried using Admin tools "Change database collation" several times, and "Repair & Otimise tables" but nothing works.
Have also cleared cache and temp directory.
Can anyone please help?
Related
When the WP Fastest Cache plugin is enabled it significantly improves the speed of my pages but somehow causes an error.
When I load the page the first time, the special characters like "TM" and "`" are correctly displayed. On mobile it works fine too.
However, when visiting or reloading the same page in the same browser the special characters are displayed as UTF-8 codes (as far as I know) and the "TM" symbol looks something like this: â„¢
I looked at my wp_config.php file and the charset is already UTF-8. it has something to do with the cache plugin but disabling it is not an option too since I really need the improved page speed.
Is there a way to fix the problem and let special characters display normally even after reloading the page?
Thanks in advance!
Deziox
Update: Found the solution myself.
Just copy the following line in your .htaccess file:
AddDefaultCharset utf-8
I know there were plenty of questions like this but I am creating the new one because to my point of view it is specific to each situation.
So, my page is displayed in UTF-8 format. The data is taken from mySQL that has utf8_unicode_ci collation. The data I am displaying is the string - 1 Bröllops-Festkläder.
There are some unicode characters in here and they should display fine but they do not. On my page these are just a bunch of hieroglyphs.
Now, the interesting situation:
I am using phpMyAdmin to keep track of what is happening in the database. The website has the ability to import CSV documents containing customer data and modify each customer individually. If I import CSV document containing these characters they are written to the database, readable in phpMyAdmin and not readable on my page. If I use my script to modify the customer information and I type those characters from the browser, the it is vice versa - they are readable on the page and they are not readable in phpMyAdmin, so clearly the encoding is different. I spent ages figuring out the right combination and I could not.
UPDATE: Deceze posted a link below that I copy here to make it more noticeable. I am sure this will save hours and days to many people facing similar issues - Handling Unicode Front to Back in a Web App
There're couple of things that got involved here. If your database encoding is fine and html encoding is fine and you still see artefact, it's most likely your db connection is not using same encoding, thus leading to data corruption. If you connect by hand, you can easily enforce utf encoding, by doing query SET NAMES UTF8 as very first thing after you connect() to your database. It is sufficient to do this only once per connection.
EDIT: one important note though - depending on how you put your data to the DB, your database content may require fixing as it can be corrupted if you put it via broken connection. So, if anyone is facing the same issue - once you set all things up, ensure you are checking on fresh data set, or you may still see things incorrectly, even all is now fine.
this is so weird, this has never happened to me. I've worked with utf-8 alot and this is the first time happening,
Since last week all my sites that had utf8 characters in files are now showing ? instead of the actual character!
the files are ok and I can see characters fine if I edit them,but after it gets processed by php it changes the utf-8 characters with ?.
the utf8 characters that were stored in database are loading just fine , but the problem is with the strings that are in php files.
Notice I said since last week, this means it happened all of a sudden and obviously something changed on server.
I contacted my hosting company but they have no clue what to look for and I don't know what to tell them to look for.
any clue what could have been changed on the server?
so to conclude:
it's not a database problem
it's not a file encoding problem (I hope not, I have 30+ sites with different cms on each one, can not afford to edit them all)
it's not a content-type issue in html because it's getting parsed by php and turns utf8 characters to ?
it could alse be a wordpress problem,but I'm sure this happend after some changes on server side
screenshot1
screenshot2
it's not a database problem - Check
it's not a file encoding problem - THIS actually could be it
it's not a content-type - Check (but make sure you write UTF-8 in meta tag lowercase !)
Wordpress problem - Maybe with combination of file encoding
I can imagine situation, when you deleted/disabled mb_string module for PHP and then edited your template using wordpress. Then your characted got shattered.
I have imported the wordpress database and full source and implemented in my local server. I started working on it and i have also updated the wordpress version and also the plugins.
now the problem is that there are weird characters coming in my posts. such as ’ instead of '.
So now shall i remove this from everywhere now. i have lots of posts and i dont want to do laborious work. can we have fire some query on wordpress database and remove this character..
Try to change the database collation to UTF-8-GENERAL
charset in MySQL
I'm making small module/plugin for my future CMS/Framework. I wanted it from begining to be with multi-language support.
I set my new database to utf8_unicode_ci (I read that it is more accurate, then utf8_general_ci)
Set my files to UTF-8 without BOM
Every page has in head Content-Type: text/html; charset=utf8
When I register new user new record is added to user table. I tried to register user with russian nickname. When I inserted it to form it was fine. Added record to table. Signed in and showed greetings fine in russian too. But when I looked at the record in table the nickname was some gibberish characters. I tried all encodings in browser. Nothing helped.
UPD: I even tried to view data with SQLyog. Shows same as phpMyAdmin.
Small screenshot of what I mean alt text http://s43.radikal.ru/i101/1006/a9/f458f64a9918.png
Could anyone explain to me, what might be the problem?
Here's an earlier answer of mine about the same problem, try that: How to display a mysql table data in another language properly in php
Every page has in head Content-Type: text/html; charset=utf8
is it meta tag or HTTP header? must be a latter one.
and you have to run SET NAMES utf8 query every time you connect to the database in your PHP scripts