What character encoding does fwrite use?

What character encoding does fwrite use by default and how can this be controlled?
<?php
   $data = "Hello. Buenos días. Ça Va. Yá'át'ééh.";
   $fp = fopen($file, 'w');
   fwrite($fp, $data);
   fclose($fp);
?>

Open in new window

LVL 16
hankknightAsked:
Who is Participating?
 
alain34Commented:
Hello hankknight,

You may be interested to look at this comment in the uk manual http://uk3.php.net/manual/en/function.fwrite.php#73764

Regards,

alain34
0
 
hankknightAuthor Commented:
alain34, your idea is to do this:

fwrite($fh,utf8_encode($myString));

The problem is that the string is ALREADY in UTF-8 encoding.  

And to double encode this could cause some problems!
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24146810.html

So I can't leave it as it is because of the UTF-8 fwrite bug you noted.  And I can't convert it because it would get scrambled!  Either way the text gets damaged!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.