ID: 45332
Updated by: [EMAIL PROTECTED]
Reported By: xpower dot ltd at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: *Unicode Issues
Operating System: Windows Server 2008
PHP Version: 5.2.6
New Comment:
You should be writing the file in binary mode:
$fh = fopen($myFile, 'wb') or die("can't open file");
Notice the 'b' there..
Previous Comments:
------------------------------------------------------------------------
[2008-06-23 00:26:30] xpower dot ltd at gmail dot com
Description:
------------
Writing file somehow messed up XML encoding ?
if we disable the part :
$myFile = "file.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,$sql);
fclose($fh);
then it is O.K. but else the encoding is messed up.
Reproduce code:
---------------
header("Content-type:text/xml");
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "UTF-8");
...
...
$sql = "SELECT id,name,in_egn,phone,mobile,city FROM contragents
".loadRole('')." name!='' and type='".iconv("UTF-8",
"UTF-8",$_GET['sort'])."' ";
$sql.= "ORDER BY ".$_GET["orderBy"]." ".$_GET["direction"]."";
$sql.= " LIMIT ".$posStart.",".$count;
$myFile = "file.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh,$sql);
fclose($fh);
$res = mysql_query ($sql);
...
...
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
if($res)
{
print("<rows total_count='".$totalCount."'
pos='".$posStart."'>\n");
for($i=0;$left= mysql_fetch_array($res);$i++)
Expected result:
----------------
expected UTF-8 getting something else ?
Actual result:
--------------
about the iconv("utf-8","utf-8"... Vista localized versions have some
encoding problems of it own, so thats a fix for that...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45332&edit=1