Changeset 11193

Show
Ignore:
Timestamp:
04/03/07 18:29:41 (2 years ago)
Author:
mloskot
Message:

Backported fix of reading GML file with UTF-8 BOM included (Ticket #1534).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/ogr/ogrsf_frmts/gml/ogrgmldatasource.cpp

    r10646 r11193  
    133133        szHeader[sizeof(szHeader)-1] = '\0'; 
    134134 
    135         if( szHeader[0] != '<'  
    136             || strstr(szHeader,"opengis.net/gml") == NULL ) 
     135/* -------------------------------------------------------------------- */ 
     136/*      Check for a UTF-8 BOM and skip if found                         */ 
     137/*                                                                      */ 
     138/*      TODO: BOM is variable-lenght parameter and depends on encoding. */ 
     139/*            Add BOM detection for other encodings.                    */ 
     140/* -------------------------------------------------------------------- */ 
     141 
     142        // Used to skip to actual beginning of XML data 
     143        char* szPtr = szHeader; 
     144 
     145        if( ( (unsigned char)szHeader[0] == 0xEF ) 
     146            && ( (unsigned char)szHeader[1] == 0xBB ) 
     147            && ( (unsigned char)szHeader[2] == 0xBF) ) 
     148        { 
     149            szPtr += 3; 
     150        } 
     151 
     152/* -------------------------------------------------------------------- */ 
     153/*      Here, we expect the opening chevrons of GML tree root element   */ 
     154/* -------------------------------------------------------------------- */ 
     155        if( szPtr[0] != '<'  
     156            || strstr(szPtr,"opengis.net/gml") == NULL ) 
    137157        { 
    138158            VSIFClose( fp );