1

I am using php in order to read a .txt file which contains any kind of characters. When I use the php function, utf8_decode() characters such as éàêô... are correctly recognized but chinese characters are displayed as ????. And when I don't use utf8_decode() the echo output of a chinese character is something like 北京å. What is stranged is that on the source code of the generated webpage the chinese characters are corectly displayed.

How can I do to have a correct output ?

I use the fgets function to creat a variable $buffer to read into the .txt file and then :

$buffer = explode(" ", $buffer);

foreach($buffer as $word){
    //$word=utf8_decode($word);
    echo "$word \n";
}

Thank you very much

user1836529
  • 209
  • 1
  • 2
  • 9

1 Answers1

0

Have a look at mb_string's different functions - http://php.net/mb_string

martin-lundberg
  • 470
  • 2
  • 8