[postgis-users] Read file encoding from from shape file

Peter Hopfgartner peter.hopfgartner at r3-gis.com
Sat Mar 13 12:11:50 PST 2010


Paul Ramsey wrote:
> I was never certain that ESRI software actually respected the DBF code
> page flags, but your reference indicates they do, so this seems
> reasonable. Some investigation of the current state of shapelib WRT
> encoding would be wise, as I think we should update our shapelib to
> the current version when we release 2.0.
>
> P.
>
>   
Indeed, shapelib supports from some time, now:

Citing the change log in dbfopen.c:

 * Revision 1.77  2007/12/15 20:25:21  bram
 * dbfopen.c now reads the Code Page information from the DBF file, and 
exports
 * this information as a string through the DBFGetCodePage function.  
This is
 * either the number from the LDID header field ("LDID/<number>") or as the
 * content of an accompanying .CPG file.  When creating a DBF file, the 
code can
 * be set using DBFCreateEx.

Regards,

Peter
> On Fri, Feb 26, 2010 at 5:55 AM, Peter Hopfgartner
> <peter.hopfgartner at r3-gis.com> wrote:
>   
>> Hi
>>
>> Looking into the sources of shp2pgsql, [0], it seems that the loader assumes
>> that the encoding of the dbf file is  "WINDOWS-1252", if not specified
>> differently by the -W command line option.
>>
>> From [1], shape files carry some information about their encoding, either in
>> the dbf file header at byte position 29, [2], or in a separate file with
>> extension CPG.
>>
>> Would it make sense to change the default behaviour of shp2pgsql into:
>>
>> 1) try to get file encoding from dbf file or cpg file
>> 2) if 1) fails, take WINDOWS-1252 as default
>> 3) if -W is given, take this option
>>
>> And then, is the information about the encoding set by pgsql2shp? It would
>> be smooth, if shapes generated by pgsql2shp could be imported by shp2pgsql
>> without specifying any encoding during import ("just works").
>>
>> Regards,
>>
>> Peter
>>
>> [0] http://trac.osgeo.org/postgis/browser/trunk/loader/
>> [1]
>> http://support.esri.com/index.cfm?fa=knowledgebase.techArticles.articleShow&d=21106
>> [2] http://www.dbase.com/knowledgebase/int/db7_file_fmt.htm
>>
>> --
>>
>> Dott. Peter Hopfgartner
>>
>> R3 GIS Srl - GmbH
>> Via Johann Kravogl-Str. 2
>> I-39012 Meran/Merano (BZ)
>> Email: peter.hopfgartner at r3-gis.com
>> Tel. : +39 0473 494949
>> Fax  : +39 0473 069902
>> www  : http://www.r3-gis.com
>>
>> XING : http://www.xing.com/go/invita/8917535
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>     
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>   


-- 
 
Dott. Peter Hopfgartner
 
R3 GIS Srl - GmbH
Via Johann Kravogl-Str. 2
I-39012 Meran/Merano (BZ)
Email: peter.hopfgartner at r3-gis.com
Tel. : +39 0473 494949
Fax  : +39 0473 069902
www  : http://www.r3-gis.com

XING : http://www.xing.com/go/invita/8917535 




More information about the postgis-users mailing list