2011年9月1日 星期四

write a file in UTF-8 format

http://php.net/manual/en/function.fwrite.php

if you have to write a file in UTF-8 format, you have to add an header to the file like this :

$f=fopen("test.txt", "wb");
$text=utf8_encode("éaè!");
// adding header
$text="\xEF\xBB\xBF".$text;
fputs($f, $text);
fclose($f);
?>