I am using excel 2010 professional plus to create an excel file. Later I try to export it to a UTF-8.csv file. I do this by saving it as a CSV (the character is separated ..... sry I do not know the exact wording there, but I do not have the English version, and I am afraid that it is not translated in the same way as 1: 1). There I click on tools-> weboptions and select unicode (UTF-8) as the encoding. An example .csv is as follows:
ID;englishName;germanName 1;Austria;Ă–sterreich
So far so good, but if I open the file now using my php code:
header('Content-Type: text/html; charset=UTF-8'); iconv_set_encoding("internal_encoding", "UTF-8"); iconv_set_encoding("output_encoding", "UTF-8"); setlocale(LC_ALL, 'de_DE.utf8'); $fp=fopen($filePathName,'r'); while (($dataRow= fgetcsv($fp,0,";",'"') )!==FALSE) { print_r($dataRow); }
- I get: sterreich as a result on the screen (since this is an “error”, I cut all the rest of the result).
- If I open the file with the marked ++ block and look at the encoding, I see "ANSI" instead of UTF-8.
- If I change the encoding in Notepad ++ to UTF8 ..., then ö, ä, ... are replaced with special characters, which I have to fix manually.
If I switch to a different route and create a new UTF-8 file with the marked ++ block and put the same data as in the excel file, "Ă–sterreich" appears on the screen when I open it with a php file.
Now I have a question why it does not work with excel, so am I doing something wrong here? Or am I not noticing something?
Edit: Since the program will ultimately be installed on the Windows servers provided by the clients, a solution is needed in which there is no need to install additional tools (php libraries, ... okay, but to install vm-ware or cygwin. .. no). In addition, the server will not have an excel server (or office) locally installed on the server, since the client will be able to download the CSV file through the file download dialog (the dialog itself is not part of the problem, since I know how to handle them, and, in addition, the problem itself that I came across when I created an excel file and converted it to .csv on testmachine where excel was locally installed).
Tpx
source share