[Qgis-user] Shapefile with file .cpg(codepage)

Bernd Vogelgesang bernd.vogelgesang at gmx.de
Thu Jul 7 05:45:28 PDT 2016


Hi Even,

the encoding is often a source of confusion. I work in a mixed  
environment, me on Linux (so UTF-8 is the "System"-default), the rest is  
using on Windows (with Windows-1252 I assume)
Transfering shapes often results in crippled data, and I have not found  
workflows/settings that this will not happen.

Is there anything I can do about it, so we do not have to adjust things  
manually all the time, or first look if the codepage is correctly set ?

Cheers
Bernd

Am 07.07.2016, 12:58 Uhr, schrieb Even Rouault  
<even.rouault at spatialys.com>:

> Le jeudi 07 juillet 2016 12:16:17, Andrea Peri a écrit :
>> Hi,
>> I have some shapefiles with an extra file having extension .cpg.
>> The .cpg extension is a optional extension for declaration of Code-Page.
>> Is this file knowed and supported from QGIS 2.14. ?
>>
>> I don't know if the qgis when loading a shapefile is using the ogr or
>> instead is using an own shapefile provider, but however I don't know
>> if gdal is knowing and using this .cpg file.
>
> Andrea,
>
> OGR does use the .cpg file when present (I'm just updating
> http://gdal.org/drv_shapefile.html since it only mentions the reading of  
> the
> codepage byte in the DBF header, but the .cpg presence overrides that)  
> and
> QGIS uses OGR to read shapefiles.
>
> But, in QGIS, the default behaviour is to make OGR *not* use the encoding
> detected by the OGR shapefile driver and use instead the user defined  
> encoding
> in the GUI. Unless you go to Settings / Options / Data Sources and  
> uncheck the
> "Ignore shapefile encoding declaration", in which case OGR will manage  
> the
> transcoding itself.
>
> Even
>


-- 
Bernd Vogelgesang
Siedlerstraße 2
91083 Baiersdorf/Igelsdorf
Tel: 09133-825374



More information about the Qgis-user mailing list