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
    Commented Dec 1, 2016 at 10:31
  • i want to get both Commented Dec 1, 2016 at 10:33

1 Answer 1


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 and acknowledge you have read our privacy policy.

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