[FWTools] ogr2ogr - preserve latin characters

Frank Warmerdam warmerdam at pobox.com
Mon Jun 27 07:21:50 EST 2011


On 11-06-26 05:56 PM, Karel Novotny wrote:
> Hello,
>
> I am using this command to convert shp to csv but all latin characters
> on the output are corrupted:
>
> ogr2ogr -f CSV -lco GEOMETRY=AS_XY output_csv input_shape
>
> Any suggestion on how to modify the comand in such a way that the latin
> encoding (Windows 1252) on the output would be preserved?

Karel,

Are you using FWTools 3.x on linux or FWTools 2.x?  FWTools 2.x should
not be attempting any conversion of characters from .dbf when reading
nor should it be doing any conversion when writing to .csv.  So I would
expect them to be unchanged.

Recently the shapefile driver has been improved to recode from win 1252
to utf-8 on read which would result in a csv file with utf-8 representations
of the latin characters instead of win1252 encoding.  This support is likely
incorporated in FWTools 3.x.  If that is what you are using and it is
causing you problems then I believe you can set the SHAPE_ENCODING
configuration variable to an empty string in order to prevent any recoding
in the shapefile driver.

eg.
export SHAPE_ENCODING=
ogr2ogr ...

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the FWTools mailing list