Byte order mark screws up file reading in Java

EDIT: I’ve made a proper release on GitHub: https://github.com/gpakosz/UnicodeBOMInputStream Here is a class I coded a while ago, I just edited the package name before pasting. Nothing special, it is quite similar to solutions posted in SUN’s bug database. Incorporate it in your code and you’re fine. /* ____________________________________________________________________________ * * File: UnicodeBOMInputStream.java * Author: … Read more

How can I output a UTF-8 CSV in PHP that Excel will read properly?

I have the same (or similar) problem. In my case, if I add a BOM to the output, it works: header(‘Content-Encoding: UTF-8’); header(‘Content-type: text/csv; charset=UTF-8’); header(‘Content-Disposition: attachment; filename=Customers_Export.csv’); echo “\xEF\xBB\xBF”; // UTF-8 BOM I believe this is a pretty ugly hack, but it worked for me, at least for Excel 2007 Windows. Not sure it’ll … Read more