[gdal-dev] Extract CGM from a NITF file

xavier lhomme lhomme.xavier at gmail.com
Wed Jun 19 13:49:53 PDT 2013


Hi

  I'm trying to extract CGM files from a NITF but the CGM are corrupt.

  First I Unescape the CGM Data and I obtain something like
   "\0,\vCreated CGM \"\0 f\0 ÿÿ\0 ...
  Then write the text file.

  I compared this string with a CGM obtained from NITRO NITF
(nitro_extract_cgm.exe).
  The new CGM file start with
    "\0,\vCreated CGM \"\0 f\0 ��\0
 I succeed to read this CGM file with a CGM viewer.

One of the difference come from caracter like ÿ (from GDAL) � from NITRO

Then It's probably something I missed in the Escaping/Unescaping function

Because UnescapeScring wasn't exposed in C# I wrote a function :
static public string UnescapeString(string pszInput)
        {
             string pszOutput="";
            int iIn = 0;
            for (iIn = 0; iIn<pszInput.Length; iIn++)
            {
                if (pszInput[iIn] == '\\')
                {
                    iIn++;
                    if (pszInput[iIn] == 'n')
                        pszOutput += '\n';
                    else if (pszInput[iIn] == '0')
                        pszOutput += '\0';
                    else
                        pszOutput += pszInput[iIn];
                }
                else
                {
                    pszOutput += pszInput[iIn];
                }
            }
            return pszOutput;
        }

thanks in advance!
Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130619/e723c4b9/attachment.html>


More information about the gdal-dev mailing list