Skip to content

Commit 164a85a

Browse files
author
Hugo Mercier
committedNov 9, 2016
[virtual] Fix encoding issue
1 parent 5093ec6 commit 164a85a

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

@@ -110,7 +110,7 @@ namespace Sqlite
110110

111111
Query& Query::bind( const QString& str, int idx )
112112
{
113-
QByteArray ba( str.toLocal8Bit() );
113+
QByteArray ba( str.toUtf8() );
114114
int r = sqlite3_bind_text( stmt_, idx, ba.constData(), ba.size(), SQLITE_TRANSIENT );
115115
if ( r )
116116
{
@@ -127,11 +127,11 @@ namespace Sqlite
127127
void Query::exec( sqlite3* db, const QString& sql )
128128
{
129129
char *errMsg = nullptr;
130-
int r = sqlite3_exec( db, sql.toLocal8Bit().constData(), nullptr, nullptr, &errMsg );
130+
int r = sqlite3_exec( db, sql.toUtf8().constData(), nullptr, nullptr, &errMsg );
131131
if ( r )
132132
{
133133
QString err = QStringLiteral( "Query execution error on %1: %2 - %3" ).arg( sql ).arg( r ).arg( errMsg );
134-
throw std::runtime_error( err.toLocal8Bit().constData() );
134+
throw std::runtime_error( err.toUtf8().constData() );
135135
}
136136
}
137137

‎src/providers/virtual/qgsvirtuallayersqlitemodule.cpp

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

0 commit comments

Comments
 (0)
Please sign in to comment.