Skip to content
Permalink
Browse files
Use QFile::encode to convert a QString containing a filename to a c-s…
…tring. Mac expects Utf8 and *nix expects local8Bit. QFile will do the right thing for each platform and not mangle Mac non-ASCII filenames.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5933 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Oct 9, 2006
1 parent 65abaf6 commit cc9c92ae95f089dfb0e3da90483d9df1a9c3ca4c
@@ -19,6 +19,7 @@
#include "qgsvectorfilewriter.h"

#include <iostream>
#include <QFile>
#include <QString>
#include <QTextCodec>

@@ -125,8 +126,8 @@ bool QgsVectorFileWriter::initialise()
return false;
}

// Filename needs toLocal8Bit().data()
mDataSourceHandle = OGR_Dr_CreateDataSource( myDriverHandle, mOutputFileName.toLocal8Bit().data(), NULL );
// Filename needs to be UTF-8 for Mac but local8Bit otherwise
mDataSourceHandle = OGR_Dr_CreateDataSource( myDriverHandle, QFile::encodeName(mOutputFileName).constData(), NULL );
if( mDataSourceHandle == NULL )
{
std::cout << "Datasource handle is null! " << std::endl;
@@ -777,7 +777,7 @@ bool QgsDelimitedTextProvider::saveAsShapefile()
}
OGRDataSource *poDS;
// create the data source
poDS = poDriver->CreateDataSource((const char *) shapefileName.toLocal8Bit(), NULL);
poDS = poDriver->CreateDataSource(QFile::encodeName(shapefileName).constData(), NULL);
if (poDS != NULL)
{
QTextCodec* saveCodec = QTextCodec::codecForName(enc.toLocal8Bit().data());
@@ -843,7 +843,7 @@ bool QgsMySQLProvider::saveAsShapefile()
}
OGRDataSource *poDS;
// create the data source
poDS = poDriver->CreateDataSource((const char *) shapefileName.toLocal8Bit(), NULL);
poDS = poDriver->CreateDataSource(QFile::encodeName(shapefileName).constData(), NULL);
if (poDS != NULL)
{
QTextCodec* saveCodec = QTextCodec::codecForName(enc.toLocal8Bit().data());
@@ -1641,7 +1641,7 @@ const std::list<std::pair<QString, QString> >& attributes)
}

OGRDataSource* dataSource;
dataSource = driver->CreateDataSource(uri.toLocal8Bit(), NULL);
dataSource = driver->CreateDataSource(QFile::encodeName(uri).constData(), NULL);
if(dataSource == NULL)
{
return false;

0 comments on commit cc9c92a

Please sign in to comment.