Jump to content

Export to CSV Encoding Problem


codemator

Recommended Posts

Hello All

I have a problem when trying to export date(in Czech) to CSV

 

Here is the code i am using

 

header("Content-type: application/force-download");

header('Content-Disposition: inline; filename="resultaat.csv"');

header("Content-Transfer-Encoding: Binary");

header("Content-length: ".strlen($sExcel));

  header('Content-Type: charset=utf-8');

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment; filename="resultaat.csv"');*

 

for($i=0;$i<count($pom);$i++){

          $out .=  $pom[$i]['msisdn'] ;

          $out .= ",";

          $out .= fixEncoding($pom[$i]['last']);

          $out .= ",";

          $out .= fixEncoding($pom[$i]['first']);

          $out .="\r\n";

          }

 

echo $out;

 

function fixEncoding($in_str)

{

    $cur_encoding = mb_detect_encoding($in_str) ;

  if($cur_encoding == "UTF-8")

    return $in_str;

  else

    return utf8_encode($in_str);

}

 

 

Please help me out ???

 

Link to comment
https://forums.phpfreaks.com/topic/158559-export-to-csv-encoding-problem/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.