du8442 2013-06-11 10:27
浏览 43
已采纳

PHP:csv文件编码?

I have a stupid problem. I use a software for export .csv files, and the result is a strange formated text. When I try to deal them in PHP, everything goes wrong.

I copy and paste the text in MS WORD : there is a strange character between each letter.

In php I tried to convert it using utf8_decode/utf8_encode, iconv("ISO-8859-1", "WINDOWS-1252", $str)... in vain.

I guess it's an utf16 encoded text, but I'm not sure of it. I tried some functions to decode utf16, in vain too.

Is someone has a solution to fix this ?

  • 写回答

1条回答 默认 最新

  • duanbu4962 2013-06-11 10:55
    关注

    Your guess it correct:

    file -i NL_JGFR_130326_bac.csv 
    NL_JGFR_130326_bac.csv: text/plain; charset=utf-16le
    

    You can probably use the PHP MultiByte extension to work with UTF-16: http://php.net/manual/en/ref.mbstring.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记