On 24 Mar 2014, at 6:04 AM, Chris Hobbs <[email protected]> wrote:
> html.py does not seem to be unicode-safe. It contains (line 1914 or
> thereabouts):
>
> components.append(OPTION(c, _value=str(c)))
>
> In my case c contains Max-Guénaël (i.e., u"Max-Gu\xe9na\xebl"). The str(c)
> dies nastily.
>
> Is this a bug or am I asking too much of web2py?
>
>
Is it practical for you to encode it yourself to utf8?
Possible a better solution, long-term: define a function, call it ustr, either
in html.py or in some utility file that does:
def ustr(s):
if isinstance(s, str):
return s
if isinstance(s, unicode):
return s.encode('utf8')
return str(s)
I think it'd be a reasonable replacement for most (not all) of html.py's str()
invocations.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.