Hi Karen,

thanks again for your reply.
I use Aptana with pydev extension.
Debugging the app shows the following for search:
dict: {u'caption': u'f\\xfcr', u'showold': False}

and for qs:
str: für
although it seems to be � instead of ASCII 252 - but this could be,
because I am sitting on a MAC
while debugging.
(the search problem itself stays the same on MAC and LINUX debian)

regards
-- Hinnack

2009/11/26 Karen Tracey <kmtra...@gmail.com>

> On Wed, Nov 25, 2009 at 1:54 AM, Hinnack <henrik.gens...@googlemail.com>wrote:
>
>> Hi Karen,
>>
>> thanks for your reply
>>
>> it means so far I must do a:
>> qs = search[query].encode('iso-8859-1')
>>
>> before I add the qs to a Q object of a queryset. Only in this case I get
>> results.
>>
>> the full codepart looks like:
>>
>> decoder = simplejson.JSONDecoder()
>> search = decoder.decode(request.POST['search'])
>> qs = search['caption'].encode('iso-8859-1')
>>
>> searchstr = urllib.unquote_plus(qs).strip('=!~')
>>
>> basic.filter( Q(evid__caption__icontains=searchstr) )
>>
>>
>> I do have no DATABASE_OPTIONS set. Maybe that's it?
>>
>
> No, there's nothing you need to set specially to get this to work.
>
> It would be interesting to see the repr of search['caption'] before and
> after you do the encode('iso-8859-1').
>
> I suspect search['caption'] is originally a Unicode object that was
> (incorrectly) constructed from a utf-8 bytestring assuming iso-8859-1
> encoding.  That would explain the results you are getting, since encoding
> such an incorrectly constructed object to iso-8859-1 will restore it to a
> utf-8 bytestring. Django, when handed a bytestring, assumes it is utf-8
> encoded and speaks utf-8 to the database, so all works.  If on the other
> hand you pass such an incorrectly built unicode object as a unicode object,
> Django will encode it using utf-8, which results in two levels utf-8
> encoding having been done, and the result won't match actual utf-8 data in
> the database.
>
> But it's also just possible that the problem is the data values in the
> database, maybe.  Confirmation of where the problem is would come from
> knowing the repr of search['caption'] before and after the encode to
> iso-8859-1.  Then we'd be sure whether to look more closely at the way in
> which search['caption'] is getting built or the database itself.
>
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to