I have a pyramid 1.2 application which processes donations made via
PayPal using a service called PayPal Instant Payment Notification.
Today, we had a donation from an international user with non-ascii
characters in their last name. PayPal makes a post request to our
server with information about the pyramid view that handles these the
request failed when I tried to access the last name from
request.params.get('last_name')

I believe requests are encoded as windows-1252, not UTF-8, which is
causing this error. Unfortunately, I do not have the option of
changing the encoding method on PayPal's end.


  File "/home/mario/webapps/mario_dyn/mario/mario/views/donate.py",
line 241, in donate_ipn
    value = request.params.get(key)
  File "/home/mario/webapps/mario_dyn/lib/python2.7/UserDict.py", line
168, in get
    return self[key]
  File "/home/mario/webapps/mario_dyn/lib/python2.7/webob/multidict.py",
line 312, in __getitem__
    return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
  File "/home/mario/webapps/mario_dyn/lib/python2.7/webob/multidict.py",
line 301, in _decode_value
    value = value.decode(self.encoding, self.errors)
  File "/home/mario/webapps/mario_dyn/lib/python2.7/encodings/utf_8.py",
line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 1:
invalid continuation byte

So, my question is, how do I tell the the request that the request is
encoded windows-1252 not utf-8, or convert it to utf-8 prior to
accessing the params MultiDict.

Thank you,
Brian

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to