I am able to set data source encoding through this answer to Setting character encoding for all layers at once using PyQGIS? and now i want to list all the datasource encodig types. how it is possible i have also check official API but nothing found!

for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    print layer.name(), layer.dataProvider().encoding() 
  • You want to list all encoding types from your layers or all encoding types available in QGIS? – Joseph Dec 1 '16 at 10:31
  • i want to get both – Muhammad Faizan Khan Dec 1 '16 at 10:33

The QgsVectorDataProvider class has the availableEncodings() method which provides you with a list of available encoding types:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.