diff --git a/src/core/qgsdatasourceuri.cpp b/src/core/qgsdatasourceuri.cpp index bce9132b0a68..82b53513482b 100644 --- a/src/core/qgsdatasourceuri.cpp +++ b/src/core/qgsdatasourceuri.cpp @@ -729,7 +729,9 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri ) void QgsDataSourceUri::setEncodedUri( const QString &uri ) { - setEncodedUri( uri.toLatin1() ); + QUrl url; + url.setQuery( uri ); + setEncodedUri( url.query( QUrl::EncodeUnicode ).toLatin1() ); } QString QgsDataSourceUri::quotedTablename() const diff --git a/tests/src/core/testqgsdatasourceuri.cpp b/tests/src/core/testqgsdatasourceuri.cpp index 7e4c75f3f7be..0866d28c2bc3 100644 --- a/tests/src/core/testqgsdatasourceuri.cpp +++ b/tests/src/core/testqgsdatasourceuri.cpp @@ -36,6 +36,7 @@ class TestQgsDataSourceUri: public QObject void checkAuthParams(); void checkParameterKeys(); void checkRemovePassword(); + void checkUnicodeUri(); }; void TestQgsDataSourceUri::checkparser_data() @@ -606,5 +607,13 @@ void TestQgsDataSourceUri::checkRemovePassword() QCOMPARE( uri2, QStringLiteral( "postgresql://user@127.0.0.1:5432?dbname=test" ) ); } +void TestQgsDataSourceUri::checkUnicodeUri() +{ + QgsDataSourceUri uri; + uri.setEncodedUri( QStringLiteral( "url=file:///directory/テスト.mbtiles&type=mbtiles" ) ); + QCOMPARE( uri.param( QStringLiteral( "url" ) ), QStringLiteral( "file:///directory/テスト.mbtiles" ) ); +} + + QGSTEST_MAIN( TestQgsDataSourceUri ) #include "testqgsdatasourceuri.moc"