note 104287 modified in function.iconv by danbrown
| From: | danbrown@php.net | Date: | Mon, 06 Jun 2011 14:18:48 +0000 |
| Subject: | note 104287 modified in function.iconv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180302@lists.php.net to get a copy of this message | ||
If you want to export some utf-8 data into csv/tsv that will be readable by excel with correct
encoding you must add special non vissable characters at the begining of file
<?php
$data = "Some utf-8 characters Ä
ÄżźÄÅ"
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Disposition: attachment; filename = "Export
'.date("Y-m-d").'.tsv"');
header('Pragma: no-cache');
//these characters will make correct encoding to excel
echo chr(255).chr(254).iconv("UTF-8", "UTF-16LE//IGNORE", $data);
?>
--was--
If you want to export some utf-8 data into csv/tsv that will be readable by excel with correct
encoding you must add special non vissable characters at the begining of file
<?
$data = "Some utf-8 characters Ä
ÄżźÄÅ"
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Disposition: attachment; filename = "Export
'.date("Y-m-d").'.tsv"');
header('Pragma: no-cache');
//these characters will make correct encoding to excel
echo chr(255).chr(254).iconv("UTF-8", "UTF-16LE//IGNORE", $data);
?>
http://php.net/manual/en/function.iconv.php