dongyanju1094 2019-06-10 18:35
浏览 161

PHP mb_detect_encoding无法从Excel检测CSV的编码

When I save an Excel file as CSV and try to get the encoding via mb_detect_encoding like this:

$data = file_get_contents($csv)
$encoding = mb_detect_encoding($data);

It always returns false. It seems it cannot detect the encoding from the Excel generated CSV file.

I even tried saving the CSV with a different encoding in Excel, but that doesn't seem to change anything about that.

enter image description here (sorry for the German UI)

What could be the reason for this and how can I fix this? I want to write a short PHP code that converts my uploaded CSV file to UTF-8 before doing any processing. But I get stuck at detecting the original encoding.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Fluent齿轮搅油
    • ¥15 八爪鱼爬数据为什么自己停了
    • ¥15 交替优化波束形成和ris反射角使保密速率最大化
    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素