Skip to content

Commit

Permalink
Set the ENCODING layer creation option when creating a new empty Shap…
Browse files Browse the repository at this point in the history
…efile. Thanks to Minoru Akagi.
  • Loading branch information
borysiasty committed Apr 25, 2013
1 parent 320d90a commit 4fb9879
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -24,8 +24,7 @@ email : sherman at mrcc.com
#include <gdal.h> // to collect version information
#include <ogr_api.h>
#include <ogr_srs_api.h>
#include <cpl_error.h>
#include <cpl_conv.h>
#include <cpl_string.h>

#include <limits>

Expand Down Expand Up @@ -1848,8 +1847,15 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
}
}

char **papszOptions = NULL;
if ( driverName == "ESRI Shapefile" )
{
papszOptions = CSLSetNameValue( papszOptions, "ENCODING", encoding.toLocal8Bit().data() );
}

OGRLayerH layer;
layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, NULL );
layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, papszOptions );
CSLDestroy( papszOptions );
if ( !layer )
{
QgsMessageLog::logMessage( QObject::tr( "Creation of OGR data source %1 failed: %2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ), QObject::tr( "OGR" ) );
Expand Down

0 comments on commit 4fb9879

Please sign in to comment.