Problem encoding csv file (PHP programming)

Discussion in 'PHP' started by Wighnomy, Nov 8, 2008.

  1. Wighnomy

    Wighnomy New Member

    Joined:
    Nov 8, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice