1

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():
    layer.setProviderEncoding(u'UTF-8')
    layer.dataProvider().setEncoding(u'UTF-8')
    print layer.name(), layer.dataProvider().encoding() 
2
  • 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

3

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

QgsVectorDataProvider.availableEncodings()

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.