I’ve got some csv-files that I need to import to our system using php. I live in Norway and we got 3 special characters (æøå and uppercase ÆØÅ). The problem is that the uppercase-versions just disappear from my strings. The lowercase ones are displayed with ?, but when using utf8_encode, I get the correct letters.
I am using the following function to import and read the csv-file. The ÆØÅ-letters are already gone when dumping $arr
$row = 1;
$arr = array();
if (($handle = fopen($imp['importBreddegave'], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
$arr[$row][$c] = $data[$c];
}
}
fclose($handle);
}
I guess I need to specify the character-encoding in some way, but I don’t manage to figure out how. By standard, cvs-files are encoded by WINDOWS-1257 as far as I found out. The rest of my page is encoded with UTF-8
Anyone got any neat tricks?
This ugly hack worked. I had to avoid using
fgetcsvandfopenHope it helps