0

I have updated my MAMP Pro to the 4.0.6 Version from 3.x today and since then I am having the problem that my local site on MAC OSX 10.11 is not supporting UTF-8 characters anymore.

So I am having for example the "ü" character in my mysql database which should show the "ü" character on my page but it does not, also when I am saving a "ü" character it saves it as a "ü" instead of "ü" in the database.

I am using the mysqli class and checked with the get_charset function that the charset of mysql connection is correct (utf8_general_ci). Also the local database and its tables have the right charset (utf8_general_ci).

I also added in the php.ini:

default_charset = "utf-8"

In my Apache http.conf I added the line

AddDefaultCharset utf-8

In my HTML-HEAD files I have the following line:

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

Still the same problem, I am thankful for any help…

EDIT: As Roland Starke and junkfoofjunkie said in the comments its totally right to save the values in the database as "ü" and not "ü" (I did it wrong for a long time). It turned out that my MAMP 4 configuration was correct, but my MAMP 3 configuration was wrong. In addition my online version which runs on Amazon RDS was wrong and not configured in UTF-8 but in Latin1, seems like RDS always is in latin by default. I did what wtravish said to correct that: Converting RDS database to UTF-8

I also had to change the content, the following sql-code helped me:

UPDATE table_name SET
column_name = REPLACE(column_name ,'ß','ß'),
column_name = REPLACE(column_name ,'ä','ä'),
column_name = REPLACE(column_name ,'ü','ü'),
column_name = REPLACE(column_name ,'ö','ö'),
column_name = REPLACE(column_name ,'Ä','Ä'),
column_name = REPLACE(column_name ,'Ü','Ü'),
column_name = REPLACE(column_name ,'Ö','Ö'),
column_name = REPLACE(column_name ,'€','€'),
column_name = REPLACE(column_name ,'°','°');

jeecode
  • 1
  • 2
  • "also when I am saving a "ü" character it saves it as a "ü" instead of "ü" in the database." -> Sounds good for me. (?!) Maybe you had a wrong charset before updating? – Roland Starke Nov 09 '16 at 16:55
  • If you have `utf-8` set correctly throughout your website, it **should** save as **ü**, not **ü**. So there is definitely something else wrong with your site. The "ü" is NOT a UTF-8 character, it's an encoding of a character that doesn't work with the character set you have - hence I'm suspecting you either had a different encoding earlier, in the database, or in the files? – junkfoodjunkie Nov 09 '16 at 17:06
  • Thank you both, it seems I have done it wrong before, so actually its correct this way... – jeecode Nov 09 '16 at 17:26
  • there's a surprising number of places the character set can be set wrong - not just in the tables and in php but in the connections between. try `mysql> show variables like 'char%';` and see if there are stray non-uff settings. – Jerry Nov 09 '16 at 20:19
  • Search for "Mojibake" in http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Nov 13 '16 at 05:55
  • Those `REPLACEs` are likely to make things _worse_. After figuring out which case you have, perform the fix [_here_](http://mysql.rjweb.org/doc.php/charcoll#fixes_for_various_cases). – Rick James Nov 13 '16 at 05:57

1 Answers1

0

edit my.cnf and put this lines on [mysqld] section:

init_connect='SET collation_connection = utf8_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake
Nissa
  • 4,636
  • 8
  • 29
  • 37