天天看點

shapefile 編碼錯誤問題解決

linux下運作,因為大部分shapefile 檔案,在使用時都沒有指定字元集,是以qgis隻能從環境變量中擷取設定環境變量中擷取SHAPE_ENCODING。

目前唯一的解決辦法就是設定環境變量

I insist that this is a QGIS issue.

GDAL 1.9.0 (and newer) is trying to interpret the encoding setting from the shape file itself. When creating a new shape file “ENCODING” should be passed as an attribute, which, obviously, is not done.

Calling qgis from terminal allows two track down an warning messages. Saving non-Latin characters in a shape files generates following warning message: “Warning 1: One or several characters couldn't be converted correctly from UTF-8 to ISO-8859-1.

This warning will not be emitted anymore”.

On the other hand, most of the shape files used by users are without character encoding byte. So QGIS has to operate with environmental variable “SHAPE_ENCODING”. At present the only solution is to use the same character coding for the given QGIS session, e.g.:

SHAPE_ENCODING=UTF-8 export SHAPE_ENCODING qgis

The example above allows to create and edit shape files with UTF-8 as a character encoding (example for Linux users, Windows users must use “SET SHAPE_ENCODING=UTF-8”).

------------------------------------------------

Excerpt from

<a href="http://trac.osgeo.org/gdal/wiki/ConfigOptions">http://trac.osgeo.org/gdal/wiki/ConfigOptions</a>

In C/C++ configuration switches can be set programmatically like this:

#include "cpl_conv.h" 

...

CPLSetConfigOption( "GDAL_CACHEMAX", "64" );

Normally a configuration option applies to all threads active in a program, but they can be limited to only the current thread this way:

<a href="http://hub.qgis.org/issues/5255#note-10">#10</a>

The Linux example above should be as follows:

繼續閱讀