Skip to content

Commit afb4739

Browse files
author
Hugo Mercier
committedNov 9, 2016
[virtual] Fix encoding issue
1 parent 15bcded commit afb4739

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed
 

‎src/providers/virtual/qgsvirtuallayersqlitehelper.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString& path, bool withExtension )
3030
sqlite3_auto_extension( reinterpret_cast < void( * )() > ( qgsvlayerModuleInit ) );
3131
}
3232
int r;
33-
r = sqlite3_open( path.toLocal8Bit().constData(), &db_ );
33+
r = sqlite3_open( path.toUtf8().constData(), &db_ );
3434
if ( withExtension )
3535
{
3636
// reset the automatic extensions
@@ -41,7 +41,7 @@ QgsScopedSqlite::QgsScopedSqlite( const QString& path, bool withExtension )
4141
{
4242
QString err = QString( "%1 [%2]" ).arg( sqlite3_errmsg( db_ ), path );
4343
QgsDebugMsg( err );
44-
throw std::runtime_error( err.toLocal8Bit().constData() );
44+
throw std::runtime_error( err.toUtf8().constData() );
4545
}
4646
// enable extended result codes
4747
sqlite3_extended_result_codes( db_, 1 );
@@ -89,12 +89,12 @@ namespace Sqlite
8989
{
9090
Query::Query( sqlite3* db, const QString& q ) : db_( db ), nBind_( 1 )
9191
{
92-
QByteArray ba( q.toLocal8Bit() );
92+
QByteArray ba( q.toUtf8() );
9393
int r = sqlite3_prepare_v2( db, ba.constData(), ba.size(), &stmt_, nullptr );
9494
if ( r )
9595
{
9696
QString err = QString( "Query preparation error on %1" ).arg( q );
97-
throw std::runtime_error( err.toLocal8Bit().constData() );
97+
throw std::runtime_error( err.toUtf8().constData() );
9898
}
9999
}
100100

@@ -107,7 +107,7 @@ namespace Sqlite
107107

108108
Query& Query::bind( const QString& str, int idx )
109109
{
110-
QByteArray ba( str.toLocal8Bit() );
110+
QByteArray ba( str.toUtf8() );
111111
int r = sqlite3_bind_text( stmt_, idx, ba.constData(), ba.size(), SQLITE_TRANSIENT );
112112
if ( r )
113113
{
@@ -124,11 +124,11 @@ namespace Sqlite
124124
void Query::exec( sqlite3* db, const QString& sql )
125125
{
126126
char *errMsg = nullptr;
127-
int r = sqlite3_exec( db, sql.toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
127+
int r = sqlite3_exec( db, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
128128
if ( r )
129129
{
130130
QString err = QString( "Query execution error on %1: %2 - %3" ).arg( sql ).arg( r ).arg( errMsg );
131-
throw std::runtime_error( err.toLocal8Bit().constData() );
131+
throw std::runtime_error( err.toUtf8().constData() );
132132
}
133133
}
134134

‎src/providers/virtual/qgsvirtuallayersqlitemodule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void initVirtualLayerMetadata( sqlite3* db )
5656
char *errMsg;
5757
if ( create_meta )
5858
{
59-
r = sqlite3_exec( db, QString( "CREATE TABLE _meta (version INT, url TEXT); INSERT INTO _meta (version) VALUES(%1);" ).arg( VIRTUAL_LAYER_VERSION ).toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
59+
r = sqlite3_exec( db, QString( "CREATE TABLE _meta (version INT, url TEXT); INSERT INTO _meta (version) VALUES(%1);" ).arg( VIRTUAL_LAYER_VERSION ).toUtf8().constData(), nullptr, nullptr, &errMsg );
6060
if ( r )
6161
{
6262
throw std::runtime_error( errMsg );

0 commit comments

Comments
 (0)
Please sign in to comment.