[gdal-dev] Encoding (FGDB)

Frank Warmerdam warmerdam at pobox.com
Thu Jun 9 11:26:01 EDT 2011


On 11-06-09 10:33 AM, Paul Ramsey wrote:
> So, the FGDB API works with (mostly) UTF16-encoded wide characters (wstring).
>
> What is the GDAL internal standard for string encoding? Looks like
> (from the OLCStringsAsUTF8 capability) there is at least a loose
> standard that is looking for UTF8 narrow characters. Are there any
> existing utilities for conversion from UTF16 to UTF8 and vice versa in
> GDAL/OGR? We have a string2wstring function in the early FGDB code,
> but as far as I can tell it is just narrowing/widening the characters,
> and any non-ASCII characters would probably get screwed on the way
> through.

Paul,

Yes, the standard for handling this is to translate to UTF8 as discussed
in:

   http://trac.osgeo.org/gdal/wiki/rfc23_ogr_unicode

To convert from UTF16 to UTF8 use CPLRecodeFromWChar() like:

   const char *pszUTF8 =
      CPLRecodeFromWChar( pwszUTF16, CPL_ENC_UCS2, CPL_ENC_UTF8 );

Make sure you CPLFree( pszUTF8 ) when you are done with it.

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 gdal-dev mailing list