[QGIS-Developer] Loading many Excel-Files in QGIS with correct encoding

Andrea Giudiceandrea andreaerdna at libero.it
Thu Jul 15 14:14:48 PDT 2021


Il 15/07/2021 22:30, Nyall Dawson ha scritto:
> I don't think that's completely correct -- looking at the freexl 
> documentation it seems that only some xls file versions are utf8, and 
> others have a codepage indicating the encoding which needs to be read 
> from the xls metadata:

Yes, of course BIFF5 (and previous versions), which is used until Excel 
95, stores internally the strings with a codepage based encoding, while 
BIFF8 (since Excel 98), stores them internally as UTF-16LE without the 
need of codepages.

Anyway the documentation states that: "FreeXL is intended to be strictly 
interoperable with SQLite and SpatiaLite, so any text string has to be 
converted to UTF-8 encoding.  GNU libiconv can easily handle any 
required charset conversion. So we can simply fetch the appropriate 
bytes, then call iconv() as appropriate, and we'll immediately get back 
the corresponding UTF-8 encoded text string."

So, if I'm not mistaken, the decoding from the proper internal codec and 
the encoding to UTF-8 is handled by the FreeXL library for both 
BIFF2/BIFF5 and BIFF8.
I've also tested a BIFF5 XLS using ogrinfo, and the output is UTF-8 
encoded, while internally

Regards.

Andrea


More information about the QGIS-Developer mailing list