Sunday, 6 September 2015

qgis - Change Shapefile data source encoding?


I tried to change the only the shapefile datasource encoding through properties and also How to encode shapefiles from LATIN1 to UTF-8? but it doesn't change it.


Without saving the QGIS project can't I directly change the shapefile datasource encoding?


I also tried this code, it shows change encoding but as I open the shapefile again it show the same old system encoding:


for layer in QgsMapLayerRegistry.instance().mapLayers().values():
layer.setProviderEncoding(u'UTF-8')

layer.dataProvider().setEncoding(u'UTF-8')
print layer.name(), layer.dataProvider().encoding()

(I am not saving QGIS project, just accessing and saving shapefile directly. When I save the project and do this task then it work correctly)



Answer



From the menubar, go to:


Settings > Options > Data Sources > Data source handling

and uncheck the Ignore shapefile encoding declaration setting:


Encoding setting



This sets all layers loaded into QGIS to be default encoded to UTF-8


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...