• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 651
  • Last Modified:

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

0
hankknight
Asked:
hankknight
1 Solution
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now