I am working on importing csv script in php. It works great, with the exception of foreign characters at the beginning of the field.
The code looks like this:
if (($handle = fopen($filename, "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
$teljing[] = $data;
fclose($handle);
}
Here is sample data showing my problem
føroyskir stavir, "Kr. 201,50"
óvirkin ting, "Kr. 100,00"
This will lead to the following
array
(
[0] => array
(
[0] => 'føroyskir stavir',
[1] => 'Kr. 201,50'
)
[1] => array
(
[0] => 'virkin ting', <--- Should be 'óvirkin ting'
[1] => 'Kr. 100,00'
)
)
I saw this behaivior documented in some comments at php.net and I tried to ini_set('auto_detect_line_endings',TRUE);detect line endings. No success.
Is anyone familiar with this problem?
Edit:
Thanks, AJ, this issue is now resolved.
setlocale(LC_ALL, 'en_US.UTF-8');
There was a solution.