Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP CSV生成-波兰字符转换为其html实体_Php_Csv_Polish - Fatal编程技术网

PHP CSV生成-波兰字符转换为其html实体

PHP CSV生成-波兰字符转换为其html实体,php,csv,polish,Php,Csv,Polish,当我尝试在Csv文件中插入波兰语字符时,波兰语字符会自动转换为各自的HTMLENTITY <?php header('Content-Type: text/csv; charset=UTF-8'); header( 'Content-Disposition: attachment;filename=reports.csv'); echo ('åĄĆĘŁŃÓŚŹŻąćęłńóśźż'); ?> Output: å&#260;&#262;&#280;&

当我尝试在Csv文件中插入波兰语字符时,波兰语字符会自动转换为各自的HTMLENTITY

<?php

header('Content-Type: text/csv; charset=UTF-8');   
header( 'Content-Disposition: attachment;filename=reports.csv');

echo ('åĄĆĘŁŃÓŚŹŻąćęłńóśźż');

?>
Output: å&#260;&#262;&#280;&#321;&#323;Ó&#346;&#377;&#379;&#261;&#263;&#281;&#322;&#324;ó&#347;&#378;&#380;

产出:260ĆĘŁŃÓŚŹŻąćęłńóśźż
我需要波兰字符显示在那里

有人能帮我解决这个问题吗

谢谢

试试这个:

<?php

header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename=reports.csv');

$data = 'åĄĆĘŁŃÓŚŹŻąćęłńóśźż';

$csv_output = '="'.$data.'"'.chr(9).chr(13);

$csv_output = chr(255).chr(254).mb_convert_encoding($csv_output, 'UTF-16LE', 'UTF-8');

echo $csv_output;

?>

另外,不要忘记将php文件保存为不带BOM的UTF-8


chr(9)
seprates字段和
chr(13)
分隔行…

尝试使用
echo(“”)
而不是
echo(“”)
即使双引号也不起作用,都德……做一件事:试试这个:
标题('Content-Type:text/plain;charset=UTF-8')$csv_输出=chr(255).chr(254).mb_转换_编码($csv_输出,'UTF-16LE','UTF-8')应该在你的代码中,这是一个我用同样的代码创建的文件,它在我的Excel 2010中为我工作:你的php文件应该是UTF-8,没有BOM,是吗?(有两个UTF-8文件,一个有BOM,一个没有BOM,一个有BOM的文件可能会导致不必要的问题,因为它会在您的php代码输出到浏览器之前输出一些内容)嘿,这真的很好…它工作得很好..感谢您为此花费的宝贵时间..非常感谢..GBU