[Qgis-developer] Find by Attribute plugin

Martin Dobias wonder.sk at gmail.com
Sat Apr 30 12:41:04 EDT 2011


Hi Joze

2011/4/24 Jože Detečnik <joze.detecnik at jkp-sg.si>

> Hello,
>
>
>
> I modified plugin by implemented like function. I use python Search
> function. It work with ASCII but not with UTF-8 character.
>
> Can any body help me, because I just begin with python.
>
>
>
> This work ASCII, error with UTF-8
>
>
>
> # like
>
>                 elif operator == "like":
>
>                   while (provider.nextFeature(f)):
>
>             fieldmap=f.attributeMap()
>
>             if re.search (str (value),fieldmap[col].toString()):
>
>                 selection.append(f.id())
>
>
>
I might want to have a deeper look at the str/unicode business in Python:
http://farmdev.com/talks/unicode/

What is the type of 'value' variable? Isn't it a QString by chance? If it
is, then you would be probably better off by using QRegExp for the search.
Or instead of doing str(value) that doesn't handle unicode characters
correctly you should use unicode(value). Or if it is a utf-8 encoded string
(or using other encoding) then decode it to a unicode string.

Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110430/3f772870/attachment.html


More information about the Qgis-developer mailing list