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():
    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)

  • You can take a look at the code in the plugin: shapefile_encoding_fixer
    – Jakob
    Commented Nov 25, 2016 at 10:15
  • can i save in shapefile through qgis without saving the project? Commented Nov 25, 2016 at 10:20
  • Have you tried right-clicking your layer and using the Save As... option?
    – Joseph
    Commented Nov 25, 2016 at 11:49
  • @Joseph yes man off course, i already mention that answer in my post! I direct open shape file into qgis project and change its encoding through save as but as i open it again it remaing to system (unchanged). Commented Nov 25, 2016 at 12:01
  • @Joseph i did not save qgis project, when i save qgis project and open shape file through it then it works correctly! Commented Nov 25, 2016 at 12:03

3 Answers 3


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

  • 1
    Thanks @Joseph additionally for future user this link also helpful hub.qgis.org/issues/13203. Actually Ignore shapefile encoding declaration checked option ignore the utf-8 settings. its ignore .cpg file. Commented Nov 28, 2016 at 6:58
  • @MohammadFaizanKhan - Most welcome and thanks for the link :)
    – Joseph
    Commented Nov 28, 2016 at 14:01

To recapitulate the different location where you can set the encoding:

When you open a shapefile: Open shp as

When you open a CSV: Add CSV

When you save a vector file: Save vector file as

In the layer properties:
Layer properties

And, as mentioned by @Joseph, you should probably uncheck the Ignore shapefile encoding declaration setting.


When you use Save As ..., you have to select a different filename, and Add file to canvas.

As a consequence, you MUST save the project too to get the new shapefile in it. The unsaved project still includes the untouched shapefile, and the wrong encoding.

BTW the Data encoding in the Layer properties is part of the project file, not the shapefile. Your code example does not write anything inside the shapefile, it changes just the layer settings of the project.

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.