Problems with umlaut

From semantic-mediawiki.org
Fragment of a discussion from Help talk:CSV format

Heiya Basil, I suspect that the problem is not SMW but Excel. Even though you export the file in UTF-8 Excel opens the file in Latin. What does e.g. Libre office do with the same file? Cheers

20:07, 6 June 2013

I've run into the same issue as well and have a patch which at least fixes it for me. I see that SMW exports the data as UTF-8, but Excel can't figure that out, and it's a bit of a hassle to import the data in the correct format. The solution to this is to add the UTF-8 byte order mark to the beginning of the string to be returned (see http://roosmaa.net/importing-utf-8-csvs-in-excel/). Also setting the delimiter to a semicolon makes Excel happy.

What I've done is add the BOM around line 106 of includes/queryprinters/SMW_QP_CSV.php:

$result .= stream_get_contents( $csv );
// Add the UTF-8 byte order mark (BOM) so that Excel can read this in as UTF-8
$result = chr(239) . chr(187) . chr(191) . $result;
16:27, 17 September 2013

I have the same problem with Excel 2013. Adding the line

$result = chr(239) . chr(187) . chr(191) . $result;

doesn't help. Has anyone an idea how to open the csv-file in Excel with the right character set?

16:11, 12 March 2015

Instead of hacking SMW core it will be more advisable to change settings in Excel. I thing this should do the trick: [1] (German only :( ). Supposedly newer versions should have similar settings, too. LibreOffice is much nicer in this respect since it politely asks upon import which charset to use.

There is also an new excel format. This may be an alternative too.


[1] http://www.rechtsmedizin.med.uni-muenchen.de/service/anleitungen_hilfe/excel_csv_utf8/index.html

18:13, 12 March 2015

I found a solution which works for me. I replaced the line:

$result = chr(239) . chr(187) . chr(191) . $result;

with:

$result = iconv("UTF-8", "CP1252", $result);
12:58, 17 March 2015