What are the differences in handling CSV files with Umlaut characters between Excel on Mac and Excel on Windows?

When handling CSV files with Umlaut characters in Excel on Mac, the characters may not be displayed correctly due to encoding differences. To solve this issue, you can specify the encoding when opening the CSV file in Excel on Mac. In Excel on Windows, Umlaut characters are usually displayed correctly without the need for specifying encoding.

// Specify encoding when opening CSV file in Excel on Mac
$csv_file = 'file.csv';
$encoding = 'UTF-8';
$data = [];
if (($handle = fopen($csv_file, 'r')) !== false) {
    while (($row = fgetcsv($handle)) !== false) {
        foreach ($row as $key => $value) {
            $row[$key] = iconv($encoding, 'UTF-8', $value);
        }
        $data[] = $row;
    }
    fclose($handle);
}

// Process data as needed
foreach ($data as $row) {
    // Do something with each row
}