[gdal-dev] Can't read column name of a gdb file with lattin letters

Even Rouault even.rouault at spatialys.com
Mon Apr 25 00:53:02 PDT 2016


Le lundi 25 avril 2016 09:23:43, Tomer a écrit :
> Hi,
> 
> I sent this post again because it wasn't sent to the mailing list in the
> first time.
> 
> I use c# bindings for GDAL and I want to read the column names of a gdb
> file.
> The problem is that if the column name is written with latin letters, e.g.
> Arabic, I get gibberish with less characters than expected.
> The problem exists because GDAL uses a string to save column names, and
> this type can only contain ascii characters.
> Therefore the openFileGdb driver skips on every second byte when reading
> the column names of a gdb file.
> 
> You can find it in the source code:
> 
> File: filegdbtable.cpp
> Line: 1689
> for(j=0;j < nColNameCarCount;j++) // FIXME> UTF16
>         osFieldName = pabyCur[2 * j]
> 
> Because it's a diffcult to change the column name type to a wstring, which
> can contain UTF8 charcaters,
> I thought of a creative way to solve the problem.
> I read all the bytes of the column name without skipping every second byte
> and save the bytes as a string
> and then, I get the column name with all the bytes in the c# bindings and
> decode them as UTF8.
> 
> Here is what i changed in the source code:
> 
> File: filegdbtable.cpp
> Line: 1689
> for(j=0;j < 2 * nColNameCarCount;j++)
>         osFieldName = pabyCur[j]
> 
> After I changed the source code and complied it, I still got gibberish with
> less characters than expected
> when I tried to read the column name from the c# bindings, so I couldn't
> decode it to UTF8.
> 
> My questions is: Why couldn't I read the column names correctly even after
> the changes I made?
Because there are certainly null bytes in it, which act as stop bytes when the 
string is copied around. The proper fix would be for the OpenFileGDB driver to 
properly recode UTF16 to UTF8. You could create a ticket in Trac with a .gdb 
attached/linked that demonstrate the issue.

> 
> If someone has another way to deal with this problem, please let me know.
> 
> Thanks,
> Tomer
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/gdal-dev-Can-t-read-column-name-of-a-g
> db-file-with-lattin-letters-tp5262714.html Sent from the GDAL - Dev mailing
> list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list