nuovo / spreadsheet-reader

A PHP spreadsheet reader (Excel XLS and XLSX, OpenOffice ODS, and variously separated text files) with a singular goal of getting the data out, efficiently
http://www.nuovo.lv/
Other
674 stars 498 forks source link

Possibility of setting input encoding for CSV #139

Open kAlvaro opened 6 years ago

kAlvaro commented 6 years ago

Unless I'm missing something there's no way to specify the input encoding of CSV files. The \SpreadsheetReader_CSV::$Encoding property is private, it's set in the constructor if Unicode BOM is found and defaults to UTF-8.

I understand it isn't a big problem if both data and app use the same encoding (no conversion will happen) but you will fail to get UTF-8 output as per the docs, which can be confusing. If encoding is not the same I guess you may get random conversions, which is worse.

erikas-tranauskas commented 6 years ago

I have same problem with XLS file encoding. It converts the file to UTF-8 by default, but I get a loss of data when reading a XLS file saved in CP-1252 encoding.

kAlvaro commented 6 years ago

@The50 I'm not familiar with XLS internals but I believe encoding information is stored within the file, thus you don't need to set it manually. If it doesn't work then it's a bug but it should probably have its own ticket.