What character encoding does fwrite use?

Posted on 2009-02-16
Last Modified: 2012-06-22
What character encoding does fwrite use by default and how can this be controlled?

   $data = "Hello. Buenos días. Ça Va. Yá'át'ééh.";

   $fp = fopen($file, 'w');

   fwrite($fp, $data);



Open in new window

Question by:hankknight
    LVL 16

    Accepted Solution

    Hello hankknight,

    You may be interested to look at this comment in the uk manual


    LVL 16

    Author Comment

    alain34, your idea is to do this:


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

    And to double encode this could cause some problems!

    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!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now