Skip to content

Commit 49b3a9d

Browse files
YoannQDQnyalldawson
authored andcommittedApr 24, 2023
Fallback to UTF-8 when no encoding is specified
1 parent 1c1e460 commit 49b3a9d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎src/core/vector/qgsvectordataprovider.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,15 @@ void QgsVectorDataProvider::setEncoding( const QString &e )
264264
{
265265
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
266266

267-
mEncoding = QTextCodec::codecForName( e.toLocal8Bit().constData() );
267+
// Use UTF-8 if no encoding is specified
268+
if ( e.isEmpty() )
269+
{
270+
mEncoding = QTextCodec::codecForName( "UTF-8" );
271+
}
272+
else
273+
{
274+
mEncoding = QTextCodec::codecForName( e.toLocal8Bit().constData() );
275+
}
268276
if ( !mEncoding && e != QLatin1String( "System" ) )
269277
{
270278
if ( !e.isEmpty() )

0 commit comments

Comments
 (0)
Please sign in to comment.