Jump to content

write to a file


suzie
 Share

Recommended Posts

Dear,through my php file, I am opening an xml file and write Arabic data to it then close it, with utf-8 encoding,but when opening the .xml file, the arabic data will not be foundhere is the code: $text_header ="<?xml version=\"1.0\" encoding=\"utf-8\"?> <?xml-stylesheet type=\"text/css\" href=\"itemcontent.css\"?> <?xml-stylesheet type=\"text/xsl\" href=\"rss2full.xsl\"?>"; $text_header1 = "<rss version=\"2.0\"> <language>ar-lb</language> <channel> <title>arabic data</title> <link>http://www.xxx.com/rss/rssMain.xml</link> <description>Lebanese Newspaper</description> <pubDate>$date</pubDate> <generator> cms</generator> <webMaster>it@xxx.com</webMaster>\n"; $text = $text_header.$text_header1. $text_main. $text_end; $filename = "../rss/rssMain.xml"; $f = fopen($filename, 'w'); if(!$f) die ("Error in opening the file \"$filename\".<BR>"); fputs($f,$text); fclose($f);*$text_main: contains arabic data,after running this code, the .xml files doesnot contain the arabic data, but if I change utf-8 to windows-1256, everything will be ok, arabic data appearsany help please

Link to comment
Share on other sites

OK... if you know you need to utf8_encode() the text, do that.Alternatively, save the PHP file as UTF-8 (from notepad, click "Save As..." and select UTF-8 from the encoding dropdown) and you won't need to utf8_encode() the text.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...