I have a website where my user can upload a file. This file contains some German umlauts (as ö and ä) and is latin_1 encoded. Now I need to convert this file to UTF-8 because this charset is used by my database.
I use the following code:
$csvFile = fopen($_FILES['file']['tmp_name'], 'r');
//parse data from csv file line by line
while(($line = fgetcsv($csvFile, 0, "\t")) !== FALSE){
$dbupload->query("INSERT INTO db (a, b, c)
VALUES ('".$line[0]."', '".$line[3]."', '".$line[1]."')");
}
}
//close opened csv file
fclose($csvFile);
If I use this code and import a latin_1 file, PHP skips every line containing an umlaut.
What can I do?
PS: The file is directly passed from the frontend (the page the user uses) to this file which processes it.