Mobile app version of vmapp.org
Login or Join
Holmes151

: Character encoding issue in mysql database when working on a MacBook (OSX 10.10) I'm attempting to get my web development environment running on my MacBook (OSX 10.10 with MAMP), but I'm stuck

@Holmes151

Posted in: #CharacterSet #Mac #Mysql #Unicode

I'm attempting to get my web development environment running on my MacBook (OSX 10.10 with MAMP), but I'm stuck on an annoying character encoding issue. When originally developing my site in a Windows environment, I went with ISO-8859-1 encoding and never had any problems with character encoding.

Now, when I run my site locally on my MacBook, I get these � characters in text pulled from the database. I tried to solve the issue by changing the database from ISO-8859-1 to UTF-8 collation: I created a new database with UTF8_unicode_ci collation, imported the tables from the old database and changed collation for tables and fields to Unicode.

Seeing that this didn't help, I made an attempt by renaming a small table, and recreating it from scratch directly in UTF8 - but to no avail.

Don't know where else to search or what to do. Can someone please point me in the right direction ?

Are there maybe any settings in php or mysql which are relevant to this and would have default settings which are different on a Mac (I've never played around with this kind of parameters on either platform).

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Holmes151

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

Unfortunately, getting character encodings right means checking multiple places. Data can be corrupted in half a dozen places. You need to go through and check each of them.


How did you import the data from your Windows machine? Did you use mysqldump? Did you copy the database tables? If you used mysqldump you need to use the --default-character-set=ISO-8859-1 option. Similarly, when importing the db on the mac, you may need to specify the character set on the command line.
When using PHP, you need to tell it what character set to use when connecting to the database..
When outputting the webpage, you need to specify the character set in the content type.


If in all these places, you use ISO-8859-1, then you shouldn't get any more corrupted data.

The biggest problem with Latin 1 as your chosen character set is that it can't represent all languages. It can only deal with Western European languages such as English, Spanish, and German. You may wish to convert to UTF-8 at some point which is a much larger character set and can accomodate pretty much all the languages on earth. Converting is not as easy as specifying ISO-8859-1 everywhere though.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme