how to create utf-8 unicodeded txt file with php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

how to create utf-8 unicodeded txt file with php?

Post by ddragas »

how to create utf-8 unicodeded txt file with php?
gunman
Forum Newbie
Posts: 10
Joined: Fri Aug 26, 2005 12:07 pm

Post by gunman »

Use

Code: Select all

<?
header("Content-type: text/plain;charset=utf-8 \r\n");
header("Content-Disposition: attachment; filename=text.txt");
echo "text file content";
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

For many utf-8 compatible readers, it may need a byte-order marker (BOM) as well.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

also take a look at http://www.php.net/manual/en/ref.mbstring.php

There's no sense in sending a UTF-8 doc if it's not full of UTF-8 content ;-)
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post by ddragas »

thank you all folks for reply

problem is solved !! :D :D :D
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

\r\n
You don't need that in the header function.
Post Reply