[gdal-dev] WFS and -where with non-ASCII characters

Even Rouault even.rouault at mines-paris.org
Tue Jan 3 04:59:57 EST 2012

Selon Ari Jolma <ari.jolma at gmail.com>:

> Jukka,
> I get: ERROR 1: 'Hämeenkylä' not recognised as an available field.
> I.e., it seems to not be confused with 'ä' - I'm using a linux, where
> the terminal may be better with UTF8. However, the message confused me,
> it is coming from OGR SQL engine, and it seems that the engine tries to
> parse the constant as a field name.
> The fix is to escape ', i.e., 'Hämeenkylä', which works.

On Linux, I suspect that the single quotes must be removed by your shell (hence
the SQL engine believes that it must test equality between a column and another
column). So the solution is to escape the single-quote, or to
double-quote the whole stuff:

-where "name='Hämeenkylä'".

On Windows, there might perhaps be a problem with the shell passing strings in
the local code page (CP1252 or whatever variant of it that is used in
Finland), whereas the WFS server perhaps expect it to be UTF-8. I'm not sure
which encoding we are supposed to send through Filter Encoding in KVP, and I'm
not sure how it is escaped (or not) currently. But if it works with Linux, it is
likely not an escaping problem, but one related with the encoding. Sending the
Filter Encoding as a POST content will likely get rid of the encoding problem
from a theoritical point of view, but there would still be the problem of
Windows passing non-UTF8 strings to the command line utilities

Jukka, I have not the means of checking for now (behind corporate firewall that
blocks your servre). But perhaps you could try with the following OGR Python
script :

from osgeo import ogr
ds = ogr.Open('WFS:http://hip.latuviitta.org/cgi-bin/tinyows')
lyr = ds.GetLayerByName('lv:pks_tilastoalue_piste')
feat = lyr.GetNextFeature()

The python shell should send UTF8 strings to GDAL.

Best regards,


More information about the gdal-dev mailing list