I am experiencing a very strange kind of encoding problem i don't really understand and never had before. I am using PHP 5.5 on an Ubuntu machine just for the info.
To the Problem
I have a simple file index.php where i want to print this simple string
<?php echo "übermotivierter"; ?>
When viewing this in the Browser i would expect following ouput
�bermotivierter
This works like expected!
To display this in the correct way i have done following steps
- Changed the encoding of my IDE ( Zend Studio ) to UTF-8 and saved the file again
-
Set the appropriate html meta tag
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
Set the appropriate php header
<?php header("Content-Type: text/html; charset=utf-8"); ?>
After doing this i would have expected this to display in a correct way but i am still getting this weired � in the output!
The workaround
To make this thing displaying correctly i had to do that
<?php echo utf8_encode("übermotivierter"); ?>
Now it displays in a correct way.
My Question
I really dont understand why i have to use utf8_encode when my document already is encoded and saved in utf-8. That doesn't make any sense to me. Any explanation to this?