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

Even Rouault even.rouault at mines-paris.org
Tue Jan 3 07:20:20 EST 2012


Selon Jukka Rahkonen <jukka.rahkonen at mmmtike.fi>:

> I took the successful query sent by Ari from the TinyOWS log and copied it
> literally into Windows and this way it works:

Yes, this confirms that the content provided on the ogr2ogr command line is
passed untransformed to OGR (so in a ANSI codepage) whereas, in the context of
the WFS server, UTF-8 is expected. Perhaps we should swith GDAL/OGR command line
utitities to use the wide-char version of main() instead of the ANSI one in
order to get command line arguments as unicode string. But I'm afraid this would
break other parts of GDAL that are not encoding aware and for which the
translation to unicode wouldn't be that great.

About Python, I did check and I was wrong. On Windows, the Python interpreter
uses the terminal encoding by default and not UTF-8.

So you could try :

from osgeo import ogr
import sys
ds = ogr.Open('WFS:http://hip.latuviitta.org/cgi-bin/tinyows')
lyr = ds.GetLayerByName('lv:pks_tilastoalue_piste')
lyr.SetAttributeFilter("name='Hämeenkylä'".decode(sys.stdin.encoding).encode('utf-8'))
feat = lyr.GetNextFeature()
feat.DumpReadable()

Or create a test.py script and make sure to open it with a editor configured in
UTF-8 (typically not notepad !) :

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from osgeo import ogr
import sys
ds = ogr.Open('WFS:http://hip.latuviitta.org/cgi-bin/tinyows')
lyr = ds.GetLayerByName('lv:pks_tilastoalue_piste')
lyr.SetAttributeFilter("name='Hämeenkylä'")
feat = lyr.GetNextFeature()
feat.DumpReadable()

(Not sure how this email will display. But the character should be typed
naturally, I mean a single 'a' with the accent, not a 2-byte thing)

>
> -Jukka-
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list