Can you fwrite() using utf-8 encoding?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sugapablo

    #1

    Can you fwrite() using utf-8 encoding?

    I want to have php write some files in utf-8 encoding (foreign characters
    are part of the text).

    What's the best method for doing this? fwrite() doesn't seem to work.


    --
    [ Sugapablo ]
    [ http://www.sugapablo.net <--personal | http://www.sugapablo.com <--music ]
    [ http://www.2ra.org <--political | http://www.subuse.net <--discuss ]

  • Daniel Tryba

    #2
    Re: Can you fwrite() using utf-8 encoding?

    Sugapablo <russ@removesug apablo.com> wrote:[color=blue]
    > I want to have php write some files in utf-8 encoding (foreign characters
    > are part of the text).
    >
    > What's the best method for doing this? fwrite() doesn't seem to work.[/color]

    Please explain? Are you have problems with:
    -writing anything to file
    -converting to utf-8
    -writing something specific to file (like a missing BOM)


    Comment

    • Robin Haswell

      #3
      Re: Can you fwrite() using utf-8 encoding?

      On Wed, 06 Jul 2005 19:22:12 -0400, Sugapablo wrote:
      [color=blue]
      > I want to have php write some files in utf-8 encoding (foreign characters
      > are part of the text).
      >
      > What's the best method for doing this? fwrite() doesn't seem to work.[/color]

      If your string is in the correct format, then $fp = fopen("file.txt ",
      "wb"); fwrite($fp, $string) will write the file in the exact same format
      your string is. However, considering PHP's Unicode support is.. well..
      appalling, I'm guessing your real problem is that PHP has the the wrong
      character encoding in the first place. You could try utf8_encode() on your
      $string first..

      -Rob

      Comment

      Working...