Unicode value

14 views
Skip to first unread message

Jason

unread,
Aug 11, 2011, 12:02:07 PM8/11/11
to pylons-...@googlegroups.com
I have a form that I put a unicode character in one of the fields. I'm not sure what I am doing wrong:
I put the character "é" (http://www.fileformat.info/info/unicode/char/e9/index.htm) into the form field and save it.

The value in request.params shows u'Test Unicod\xc3\xa9' -- I think this should be u'Test Unicod\xe9' if it was properly decoded to utf-8. 

Is there somewhere I need to specify Pyramid to decode the posted values as UTF-8?

Thanks,

Jason

Chris McDonough

unread,
Aug 11, 2011, 12:23:52 PM8/11/11
to pylons-...@googlegroups.com

https://docs.pylonsproject.org/projects/pyramid/1.1/narr/views.html#handling-form-submissions-in-view-callables-unicode-and-character-set-issues

>
>
> Thanks,
>
>
> Jason
> --
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/xKJaDiSidioJ.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discuss
> +unsub...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.


Jason

unread,
Aug 11, 2011, 1:44:57 PM8/11/11
to pylons-...@googlegroups.com
Groovy. 

It looks like setting the charset class attribute of a request subclass is deprecated, yet the documentation advises this at https://docs.pylonsproject.org/projects/pyramid/1.1/narr/webob.html#unicode

Setting charset as an instance variable on my Request subclass instance worked though:

class RequestWithUser(Request):
    def __init__(self, *args, **kwargs):
         Request.__init__(self, *args, **kwargs)
         self.charset = 'utf-8'

And I had to switch to using webhelpers.util.html_escape instead of webhelpers.html.escape.

-- Jason
Reply all
Reply to author
Forward
0 new messages