Question

I need to learn all these encoding stuffs well. Because this is the third time I'm wasting my time with silly wrong encoding problems. Here is the problem:
I have a simple php file.

  • File is in the format of UTF-8
  • If I run my local server, it makes ı => ı and ö => Ãœ
  • If I rename extension as HTML it works perfectly, so the problem is local server, definetely.

To correct this issue, I have done the following

  1. I've read this, this and this
  2. Double checked the file encoding, it's UTF-8
  3. Added the meta tag <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. Added the header inside php tag: header("Content-type:text/html; charset: UTF-8");
  5. Added the internal encoding inside php tag mb_internal_encoding('UTF-8');
  6. Corrected the line in php.ini file default_charset = UTF-8
  7. Added the following in httpd.conf file: AddDefaultCharset utf-8
  8. Everything is hard-coded, so I don't use database, it's not related to mysql encoding

I'm using WAMP, and machine is Windows 7 English. I'm completely exhausted, therefore, I really need help.
Thanks.

Was it helpful?

Solution 2

In the end I found problem. I wrote

header("Content-type:text/html; charset: UTF-8"); 

After Content-Type, we need to have put : but after Charset we need to put equal sign = which was very frustrating for me. So,

header('Content-Type: text/html; charset=utf-8');

solves the problem.

OTHER TIPS

Checks whether the document encoding is UTF-8 without BOM

and if does not work try utf8_encode() and utf8_decode()

EDIT

$text = "A strange string to pass, maybe with some ø, æ, å characters."; 

foreach(mb_list_encodings() as $chr){ 
        echo mb_convert_encoding($text, 'UTF-8', $chr)." : ".$chr."<br>";    
 } 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top