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.
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.