Getting string attribute from a shapefile with GDAL Feature.GetFieldAsString(name) returns incomplete value

by Maxim Gritsenko   Last Updated September 11, 2019 18:22 PM

I read a shapefile (zipped) with GDAL library in C#. Shapefile contains .cpg file with "UTF-8" encoding specified.

When I call Feature.GetFieldAsString(attributeName) some of the attribute values get trimmed at the end, and some have broken symbols.

Converting shapefile to GeoJSON with ogr2ogr makes a GeoJSON file with all attributes as they are supposed to be.

For example, value returned by GetFieldAsString is "\"Тер�", when the real value, also seen in geojson is "\"Терем+\"".

This doesn't seem to be an issue with encoding, for the beginning of the string is read correctly. But I have no clue where to look for the solution for this issue.

Tags : gdal c# ogr


Related Questions


When should I use gdal_merge?

Updated February 22, 2018 16:22 PM


Masking areas outside of polygon with GDAL

Updated May 14, 2019 09:22 AM

Mosaic Imagery using GDAL Edited

Updated November 29, 2017 20:22 PM