Changeset 30994
- Timestamp:
- Oct 13, 2015, 8:36:52 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
autotest/utilities/test_ogr2ogr_lib.py (modified) (1 diff)
-
gdal/apps/ogr2ogr_lib.cpp (modified) (3 diffs)
-
gdal/apps/ogrinfo.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/autotest/utilities/test_ogr2ogr_lib.py
r30907 r30994 79 79 gdal.Unlink('/vsimem/sql.txt') 80 80 81 # Test @filename syntax with a UTF-8 BOM 82 if sys.version_info >= (3,0,0): 83 gdal.FileFromMemBuffer('/vsimem/sql.txt', '\xEF\xBB\xBFselect * from poly'.encode('LATIN1')) 84 else: 85 gdal.FileFromMemBuffer('/vsimem/sql.txt', '\xEF\xBB\xBFselect * from poly') 86 ds = gdal.VectorTranslate('', srcDS, format = 'Memory', SQLStatement='@/vsimem/sql.txt') 87 if ds is None or ds.GetLayer(0).GetFeatureCount() != 10: 88 gdaltest.post_reason('fail') 89 return 'fail' 90 gdal.Unlink('/vsimem/sql.txt') 91 81 92 return 'success' 82 93 -
trunk/gdal/apps/ogr2ogr_lib.cpp
r30948 r30994 3719 3719 } 3720 3720 3721 /************************************************************************/ 3722 /* RemoveBOM() */ 3723 /************************************************************************/ 3724 3725 /* Remove potential UTF-8 BOM from data (must be NUL terminated) */ 3726 static void RemoveBOM(GByte* pabyData) 3727 { 3728 if( pabyData[0] == 0xEF && pabyData[1] == 0xBB && pabyData[2] == 0xBF ) 3729 { 3730 memmove(pabyData, pabyData + 3, strlen((const char*)pabyData) + 1); 3731 } 3732 } 3721 3733 3722 3734 /************************************************************************/ … … 3885 3897 VSIIngestFile( NULL, papszArgv[i] + 1, &pabyRet, NULL, 1024*1024) ) 3886 3898 { 3899 RemoveBOM(pabyRet); 3887 3900 psOptions->pszSQLStatement = (char*)pabyRet; 3888 3901 } … … 4042 4055 VSIIngestFile( NULL, papszArgv[i] + 1, &pabyRet, NULL, 1024*1024) ) 4043 4056 { 4057 RemoveBOM(pabyRet); 4044 4058 psOptions->pszWHERE = (char*)pabyRet; 4045 4059 } -
trunk/gdal/apps/ogrinfo.cpp
r30864 r30994 60 60 61 61 /************************************************************************/ 62 /* RemoveBOM() */ 63 /************************************************************************/ 64 65 /* Remove potential UTF-8 BOM from data (must be NUL terminated) */ 66 static void RemoveBOM(GByte* pabyData) 67 { 68 if( pabyData[0] == 0xEF && pabyData[1] == 0xBB && pabyData[2] == 0xBF ) 69 { 70 memmove(pabyData, pabyData + 3, strlen((const char*)pabyData) + 1); 71 } 72 } 73 74 /************************************************************************/ 62 75 /* main() */ 63 76 /************************************************************************/ … … 152 165 VSIIngestFile( NULL, papszArgv[iArg] + 1, &pabyRet, NULL, 1024*1024) ) 153 166 { 167 RemoveBOM(pabyRet); 154 168 pszWHERE = (char*)pabyRet; 155 169 } … … 168 182 VSIIngestFile( NULL, papszArgv[iArg] + 1, &pabyRet, NULL, 1024*1024) ) 169 183 { 184 RemoveBOM(pabyRet); 170 185 pszSQLStatement = (char*)pabyRet; 171 186 }
Note:
See TracChangeset
for help on using the changeset viewer.
