0

I'm trying to move a site and I'm really baffled with the problems I'm having trying to sort out the encoding issues with the database.

The database on new server is using utf8 and all tables imported have utf8. Checking the exported sql file with 'file db.sql' it also says: UTF-8 Unicode text as well as it has it defined in the sql queries in the sql file.

in php.ini I've set default_charset = "UTF-8" and apache.conf I've set AddDefaultCharset UTF-8 as well have I added to the sites-enabled (regular and https) in Apache: AddDefaultCharset UTF-8

In the HTML/PHP document header I have:

  <meta http-equiv="content-type" content="text/html; charset=UTF-8">

I've checked the PHP documents served by the new web server with 'file' and these as well are: HTML document, UTF-8 Unicode text

Besides all of this, encoding is not correct neither in the mysql client nor when served via the web server. For example, ö becomes ö, å becomes Ã¥ and ä becomes ä. utf8_decode in PHP does display the text properly so it seems to be correct encoding at least?

If someone can give me a hint to where I might have gone wrong it would be greatly appreciated. I'm completely clueless. To me it all seems to have been set to UTF-8 yet these issues persist.

EDIT/add: Response headers when fetching a document from the new server also says: Content-Type text/html; charset=UTF-8

EDIT 2: Stackoverflow suggests that this has already been solved, but I do not find a solution that works from the link provided.

12
  • So, you've mangled your data while re-importing it and your database is now actually storing "ö"…? Commented Aug 21, 2017 at 8:20
  • No, database already has the chars like ö when looking at it in plain text before doing the import to mysql. Commented Aug 21, 2017 at 8:35
  • So your data is messed up at the database level. Probably an incorrect export from the old database?! Commented Aug 21, 2017 at 8:36
  • When viewing the database in phpmyadmin at the current mysql server (not new one) the chars are messed up there as well. Although I can not speak for the web server/mysql as the website is on web hosting, I do know that the headers from server and php documents are utf-8. Commented Aug 21, 2017 at 8:40
  • I really have no idea where this went wrong. All DB-text looks fine on the current website. Commented Aug 21, 2017 at 8:40

0