[gdal-dev] Re: Handling CPG (encoding) file

Alexander Bruy alexander.bruy at gmail.com
Tue May 25 13:00:30 EDT 2010


GIS-Lab community has worked on this and here is our results.
We develop a patch which add two methods GetEncoding and SetEncoding.
At this time only GetEncoding for shapefiles is realised. With this
methods programmer can get encoding programmatically. Patch
uploaded to the bugtracker: http://trac.osgeo.org/gdal/ticket/882

How this works: first we try to read DBF LDID and get encoding from
here (even CPG file is available), if LDID is 0 or 87 (system encoding)
driver will try to read encoding from CPG file.

Encoding in CPG file can be written according to the DBF LanguageID
standard or according to the codepages ANSI, OEM etc. GetEncoding
method will handle all this variants automatically.

We'd appreciate if someone could have a look and sign off or comment on the 
proposed patch.

On Sun, 23 May 2010 19:11:46 +0300
Alexander Bruy <alexander.bruy at gmail.com> wrote:

> Hi devs,
> few days ago in qgis-developer mailing list we discuss codepage handling
> in QGIS and GDAL
> http://osgeo-org.1803224.n2.nabble.com/adding-encoding-file-td5075541.html.
> Also there is post in this list with related problem
> http://osgeo-org.1803224.n2.nabble.com/gdal-dev-DBF-unicode-problem-td5075730.html
> Seems than shapelib supports codepages in CPG file and LDID both for
> reading and creating DBFs. But OGR doesn't seem to use or expose that
> functionality.
> Our community want to add to the OGR shapefile driver ability to
> read/write CPG file and ready to work on this and create a patch.
> Any hints and suggestions are welcome. We really need this
> functionality

Alexander Bruy

More information about the gdal-dev mailing list