[gdal-dev] Writing non-ASCII characters to shapefile

Francis Markham fmarkham at gmail.com
Fri Jul 2 22:40:03 EDT 2010


Hi there,

I'm trying to write data from a Microsoft Excel .xls file into a
shapefile, using OGR's Python bindings in Python 2.6.  This is going
well, but I am having some problems when I try to write values that
contain so-called "smart quotes".  Smart quotes are special
characters, defined as characters 0x91 through 0x94 in Windows-1252 (
see http://msdn.microsoft.com/en-au/goglobal/cc305145.aspx ).

What is the best way to save this data to a shapefile using OGR?  I
need the shapefile to be interoperable with other programs, including
but not limited to ESRI products. While I assume I could simply
translate these characters to standard ASCII, I would prefer not to if
possible.  I also haven't tested the shapefiles with data from other
character encodings.

I have heard that the use of UTF-8 in shapefiles is not portable.  I
am also aware that shapefile.cpg can store a shapefile's codepage.  I
don't know how to put these pieces together to create a portable
solution, however.

Apologies if this is a newbie question, but I can't find answers on the web.

Thanks,

Francis Markham


More information about the gdal-dev mailing list