Skip to content

Commit

Permalink
vector provider: fetch codec list from Qt and default to System when …
Browse files Browse the repository at this point in the history
…a unavailable codecs is requested (might cure issueID #4801)
  • Loading branch information
jef-n committed Jan 14, 2012
1 parent 50cdcc3 commit 8930633
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/qgsvectordataprovider.cpp
Expand Up @@ -23,6 +23,7 @@
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgslogger.h"
#include "qgsmessagelog.h"

QgsVectorDataProvider::QgsVectorDataProvider( QString uri )
: QgsDataProvider( uri )
Expand Down Expand Up @@ -157,7 +158,9 @@ void QgsVectorDataProvider::setEncoding( const QString& e )
}
else
{
QgsDebugMsg( "error finding QTextCodec for " + e );
QgsMessageLog::logMessage( tr( "Codec %1 not found. Falling back to system locale" ).arg( e ) );
mEncoding = QTextCodec::codecForName( "System" );
Q_ASSERT( mEncoding );
}
}

Expand Down Expand Up @@ -457,6 +460,12 @@ const QStringList &QgsVectorDataProvider::availableEncodings()
{
if ( smEncodings.isEmpty() )
{
foreach( QString codec, QTextCodec::availableCodecs() )
{
smEncodings << codec;
}
qSort( smEncodings );
#if 0
smEncodings << "BIG5";
smEncodings << "BIG5-HKSCS";
smEncodings << "EUCJP";
Expand Down Expand Up @@ -502,6 +511,7 @@ const QStringList &QgsVectorDataProvider::availableEncodings()
smEncodings << "Apple Roman";
smEncodings << "TIS-620";
smEncodings << "System";
#endif
}

return smEncodings;
Expand Down

0 comments on commit 8930633

Please sign in to comment.