GDAL/OGR 1.9.0获取shp文件中中文字段值和属性值乱码文件解决

标签:
杂谈 |
分类: GDAL |
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8","NO");
-
OGRShapeLayer::OGRShapeLayer(
OGRShapeDataSource* poDSIn, -
const char * pszName, -
SHPHandle hSHPIn, DBFHandle hDBFIn, -
OGRSpatialReference *poSRSIn, int bSRSSetIn, -
int bUpdate, -
OGRwkbGeometryType eReqType ) -
-
{
-
poDS = poDSIn; -
poSRS = poSRSIn; -
bSRSSet = bSRSSetIn; -
-
pszFullName = CPLStrdup(pszName); -
-
hSHP = hSHPIn; -
hDBF = hDBFIn; -
bUpdateAccess = bUpdate; -
-
iNextShapeId = 0; -
panMatchingFIDs = NULL; -
-
bCheckedForQIX = FALSE; -
hQIX = NULL; -
-
bSbnSbxDeleted = FALSE; -
-
bHeaderDirty = FALSE; -
-
if( hSHP != NULL ) -
{ -
nTotalShapeCount = hSHP->nRecords; -
if( hDBF != NULL && hDBF->nRecords != nTotalShapeCount ) -
{ -
CPLDebug("Shape", "Inconsistant record ,number in .shp (%d) and in .dbf (%d)" -
hSHP->nRecords, hDBF->nRecords); -
} -
} -
else -
nTotalShapeCount = hDBF->nRecords; -
-
eRequestedGeomType = eReqType; -
-
bTruncationWarningEmitte d = FALSE; -
-
-
if( hDBF != NULL && hDBF->pszCodePage != NULL ) -
{ -
CPLDebug( "Shape", "DBF Codepage ,= %s for %s" -
hDBF->pszCodePage, pszName ); -
-
// Not too sure about this, but it seems like better than nothing. -
osEncoding = ConvertCodePage( hDBF->pszCodePage ); -
} -
-
if( CPLGetConfigOption( "SHAPE_ENCODING",NULL ) != NULL ) -
osEncoding = CPLGetConfigOption( "SHAPE_ENCODING", "" ); -
-
if( osEncoding ""!= ) -
CPLDebug( "Shape", "Treating as ,encoding '%s'." osEncoding.c_str() ); -
-
poFeatureDefn = SHPReadOGRFeatureDefn( CPLGetBasename(pszName), -
hSHP, hDBF, osEncoding ); -
-
-
poPrevLayer = NULL; -
poNextLayer = NULL; -
bHSHPWasNonNULL = hSHPIn != NULL; -
bHDBFWasNonNULL = hDBFIn != NULL; -
eFileDescriptorsState = FD_OPENED; -
TouchLayer(); -
}
CPLSetConfigOption("SHAPE_ENCODING","");