0
votes

I have CSV file with special characters ØÅÆ When I use fgetcsv, it just ignores the rest of the string. I tried var_dump for the row, but I got it like this: ���

This is the code that I have:

if (($handle = fopen($path, "r")) !== FALSE) {
            while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
                var_dump($data); die;
            }
            fclose($handle);
        }

I tried adding this before my code setlocale(LC_ALL, 'en_US.UTF-8'); but without any luck. Do you have any advice?

Some sample data - first row from CSV:

VAR,E,5704617332886,500,11,"TURKISøåæØÅÆ","110"
1
you can try sending a header('Content-Type: text/html; charset=utf-8'); from PHP? Might solve the issue when printing the data. - UrGuardian4ngel
I have that already on the file top where am I printing data - user2331875
ah... Bummer :) Can you provide some sample data in your question, for testing purposes? - UrGuardian4ngel
added some sample data - user2331875
well, the header comment I stated, works like a charm to me? Setting the header before of the var_dump (and your code) prints the sample as-is, without ignoring parts of the line? - UrGuardian4ngel

1 Answers

0
votes

The proper encoding should be ISO-8859-1. That was the problem