Jump to content

write to a file


suzie

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...