Hello, the data in my database is encoded in a wrong way. Now I am trying to replace characters during the runtime, but I see no effect. This is the code I am using: $decode_ary = array( 'ü' => 'ü', 'ä' => 'ä', 'ß' => 'ß', 'ö' => 'ö', 'Ü' => 'Ü', 'Ä' => 'Ä', 'é' => 'é', 'ã' => 'ã', 'ü' => 'ü', 'ä' => 'ä', 'ß' => 'ß', 'ö' => 'ö', 'Ü' => 'Ü', 'Ä' => 'Ä', 'é' => 'é', 'ã' => 'ã', '©' => '©', 'a' => 'A', ); $topic_title = str_ireplace(array_keys($decode_ary), array_values($decode_ary), $topic_title); Code (markup): Example: Baseballschläger --> BAseballschläger But the code returns: BAseballschläger ...The a is replaced by A (it's just a check if the replace-function works properly), but the actual char combination is not replaced. Why?
str_replace only works with one-byte characters. Your database may contain multi-byte sequences representing those characters. Without knowing your database connection encoding and display encoding it's hard to say. As a starting point, you may want to try outputting the strings as fetched from the database byte-by-byte to see what's really in there.
Very trange thing happens... I discovered that using utf8_decode almost all letters are converted correctly, except for ß. Instead of Groß the result is Gro�?. Why is there such inconsistency? utf8_decode($topic_title)
Maybe the ß character was stored in a different encoding and your browser is being overly helpful by displaying it anyway. Look at the actual bytes being stored and your mystery will be solved.