Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Problem encoding csv file (PHP programming) (http://www.go4expert.com/forums/encoding-csv-file-php-programming-t15064/)

Wighnomy 9Nov2008 04:26

Problem encoding csv file (PHP programming)
 
Hi,

I'm developing an application that export some data to a csv file.

I use this code to encode my php script file:
header('Content-Type: text/html; charset=utf-8');

and this one to encode the database data:
$pgdb->query('SET CHARACTER SET latin1');

Later when I use this other for encode the download file:
header('Content-type: text/plain, charset= ISO-8859-1');
header('Content-Disposition: attachment; filename="digitalbank.csv"');

Well, I tried every combination of charsets, and always have problems when the data have specials chars, like spanish accented words...
I tried utf-8 codification, and ISO-8859-x, and never suceed in special chars representation.
I tried to change the transfer encoding
header('Content-transfer-encoding: base64');

But still have this problem.
The strange thing is that in the web, data appears correctly.
But the download csv file, never appears like an ansi encoded file.
In notepad it seems to be near to correct representation, but this not happen in other edit applications that draw weird chars....

Anyone can help me please?


All times are GMT +5.5. The time now is 07:49.