[gdal-dev] MapInfo File vs ESRI Shapefile attribute value encoding
Even Rouault
even.rouault at mines-paris.org
Wed Apr 30 06:31:20 PDT 2014
Le mardi 29 avril 2014 21:32:11, Max Demars a écrit :
> Hi,
>
> I am a bit confused right now about a possible difference in encoding
> attribute value that I have noticed between those two drivers (MapInfo File
> vs ESRI Shapefile).
>
> I have a script that allow user to export some features from database to
> shapefile or MapInfo TAB format. However, in MapInfo TAB the attributes are
> not encoded correctly in utf-8, contrary than shapefiles.
>
> The same data and the same code is used, and I am starting to think that
> the difference is coming from inside the OGR drivers.
>
> OGRFeature.SetField("FiedlName", value.encode('utf-8')) #value is unicode
>
> Anybody have information about this issue? I dont really know where to
> look.
Works for me :
$ cat foo.csv
id,text,WKT
1,éven,"POINT(0 0)"
$ file foo.csv
foo.csv: UTF-8 Unicode text
$ ogr2ogr -f "mapinfo file" foo.tab foo.csv
$ ogrinfo foo.tab -al
Had to open data source read-only.
INFO: Open of `foo.tab'
using driver `MapInfo File' successful.
Layer name: foo
Geometry: Point
Feature Count: 1
Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
Layer SRS WKT:
LOCAL_CS["Nonearth",
UNIT["Meter",1.0]]
id: String (254.0)
text: String (254.0)
WKT: String (254.0)
OGRFeature(foo):1
id (String) = 1
text (String) = éven
WKT (String) = POINT(0 0)
Style = SYMBOL(a:0,c:#000000,s:12pt,id:"mapinfo-sym-35,ogr-sym-10")
POINT (0 0)
>
> -Max Demars
--
Geospatial professional services
http://even.rouault.free.fr/services.html
More information about the gdal-dev
mailing list