With UTF-8 parameters it doesn't work.

I think the issue is with "quote"
I don't know why but quote works with UTF-8 string (but it depends on
the system) then unquote removes all special char

Maybe we have to convert UTF-8 string to string (encode/decode) then
quote the string

>>> p = u'François Vallé'
>>> pe = p.encode('utf8')
>>> pe
'Fran\xc3\xa7ois Vall\xc3\xa9'
>>> peq = urllib.quote(pe)
>>> peq
'Fran%C3%A7ois%20Vall%C3%A9'
>>> pequq = urllib.unqote(peq)
>>> pequq = urllib.unquote
>>> pequq = urllib.unquote(peq)
>>> pequq
'Fran\xc3\xa7ois Vall\xc3\xa9'
>>> pequq.decode('utf-8')
u'Fran\xe7ois Vall\xe9'
>>> p
u'Fran\xe7ois Vall\xe9'
>>>

I didn't test "live" because quote/unqote seems totaly useless now.
I think all modern browsers/servers,... handle properly UTF8 values


On 4 avr, 02:01, Alkis Evlogimenos ('Αλκης Ευλογημένος)
<[email protected]> wrote:
> You need to unquote the parameter:
> import urllib
>
> name = urllib.unquote(self.request.get('name'))
>
>
>
> On Fri, Mar 27, 2009 at 10:56 AM, Sylvain <[email protected]> wrote:
>
> > Hi,
>
> > All my app (pages, variables,...) is encoded in UTF-8 and now I'm
> > trying to send a parameter ('name') in the url like that :
>
> >http://appid.appspot.com/profile?name=François<http://appid.appspot.com/profile?name=Fran%C3%A7ois>Vallé
>
> > Server side I get the name info like that and it works fine :
> > name = self.request.get('name')
> > >> print name
> > >> François Vallé
> > The WebOb object is a UnicodeMultiDict.
> > So everything works fine.
>
> > In order to be "cleaner", I wanted to quote/unquote the parameters
> > So now my url is like that :
> >http://appid.appspot.com/profile?name=Fran%E7ois%20Vall%E9
> > Server side I get the name info like and now it doesn't work
> > name = self.request.get('name')
> > >> print name
> > >> Franois Vall
> > The WebOb object is MultiDict (not an unciode one)
> > So now all special chars are lost.
>
> > So my question is how to handle "unicode" parameter properly and
> > particularly if we want to quote/unquote them ?
> > Currently, I do no quote/unquote and it works fine,...
>
> --
>
> Alkis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to