vector layer encoding default not saved not configurable
|Assigned to:||-||% Done:||
|Target version:||Version 2.0.0|
|Platform version:||Affected version:||master|
|Status info:||Causes crash or corruption:||No|
Working with shapefiles with encoding that is not UTF-8 (say ISO-8859-1) is cumbersome because there is no way to automatically set the encoding to the proper value.
This could be accomplished by one of the following:
- saving the encoding chosen in the layer properties as a value in the .qml file for subsequent loading (in the General tab->Provider Specific->Encoding)
- project-wide default
- default in the user options
|related to Quantum GIS Desktop - Bug #5911: Language Driver ID in dbf file of new shapefile||Closed||06/30/2012|
Updated by Minoru Akagi 10 months ago
The encoding of vector layer is stored in QGIS project file(*.qgs).
When QgsOpenVectorLayerDialog("Add vector layer"), QgsVectorLayerSaveAsDialog("Save vector layer as") or QgsEncodingFileDialog(such as "New Shapefile Layer") is shown, the name of last used encoding in the dialog boxes is selected as the value of encoding combo-box.
Perhaps you will open the vector layer files by drag-and-drop. In my case, a shapefile dataset without specified codepage opened by drag-and-drop, the encoding of the layer provider has been set to "System". If the encoding was set to the last used codepage as well, it might be easier to use.
Will a default be more preferable than the last used value?
Updated by Etienne Tourigny 10 months ago
In my case, I have seen this with shapefiles in ISO-8859-1 encoding and no cpg file.
When I open the file in qgis (via commandline or from the browser dock), the encoding is set to System, and if I go and set the encoding to ISO-8859-1 it is fine. If I click "save default", a .qml file is generated but without any encoding information. So when I close qgis and re-open the file, System encoding is seleceted again and I have to re-set the encoding.
GDAL 1.9 does not recognize the encoding, I have to set SHAPE_ENCODING=ISO-8859-1 or else accented characters are garbled. When SHAPE_ENCODING is set before starting qgis, then the encoding is fine. I will try with latest ogr (from svn trunk) and see if that fixes.
I don't think that "last encoding" should be used (because it might not be ok for the next file), but rather encoding should be stored inside the .qml file (in addition or instead of .qps file). A specific file encoding does not pertain to a project but to a file. Say you would have many files but with different encodings in the same project, or you would have the same file in different projects.