Skip to content

Commit

Permalink
Use QFile::encode to convert a QString containing a filename to a c-s…
Browse files Browse the repository at this point in the history
…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@5933 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Oct 9, 2006
1 parent ead5879 commit 94b9c13
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/gui/qgsvectorfilewriter.cpp
Expand Up @@ -19,6 +19,7 @@
#include "qgsvectorfilewriter.h"

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

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mysql/qgsmysqlprovider.cpp
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 94b9c13

Please sign in to comment.