Skip to content

Commit c05dca9

Browse files
author
Hugo Mercier
committedNov 9, 2016
[virtual] Fix encoding issue
1 parent 4218f14 commit c05dca9

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 );
@@ -91,12 +91,12 @@ namespace Sqlite
9191
: db_( db )
9292
, nBind_( 1 )
9393
{
94-
QByteArray ba( q.toLocal8Bit() );
94+
QByteArray ba( q.toUtf8() );
9595
int r = sqlite3_prepare_v2( db, ba.constData(), ba.size(), &stmt_, nullptr );
9696
if ( r )
9797
{
9898
QString err = QString( "Query preparation error on %1: %2" ).arg( q ).arg( sqlite3_errmsg( db ) );
99-
throw std::runtime_error( err.toLocal8Bit().constData() );
99+
throw std::runtime_error( err.toUtf8().constData() );
100100
}
101101
}
102102

@@ -109,7 +109,7 @@ namespace Sqlite
109109

110110
Query& Query::bind( const QString& str, int idx )
111111
{
112-
QByteArray ba( str.toLocal8Bit() );
112+
QByteArray ba( str.toUtf8() );
113113
int r = sqlite3_bind_text( stmt_, idx, ba.constData(), ba.size(), SQLITE_TRANSIENT );
114114
if ( r )
115115
{
@@ -126,11 +126,11 @@ namespace Sqlite
126126
void Query::exec( sqlite3* db, const QString& sql )
127127
{
128128
char *errMsg = nullptr;
129-
int r = sqlite3_exec( db, sql.toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
129+
int r = sqlite3_exec( db, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
130130
if ( r )
131131
{
132132
QString err = QString( "Query execution error on %1: %2 - %3" ).arg( sql ).arg( r ).arg( errMsg );
133-
throw std::runtime_error( err.toLocal8Bit().constData() );
133+
throw std::runtime_error( err.toUtf8().constData() );
134134
}
135135
}
136136

‎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.