Hi Massimo,
Here's a simple test example:
Controller:
def utfinput():
s = u'\u2026'
form = FORM('Test',
INPUT(_name='test1', value=s),
INPUT(_name='doit',
_type='submit', _value='Submit'))
if form.accepts(request.vars, session):
session.flash = "Accepted"
return dict(form=form)
View:
{{ extend 'layout.html' }}
{{= form }}
Resulting html:
<form method="post" enctype="multipart/form-data" action="#">Test<input
type="text" value="…" name="test1"><input type="submit" value="Submit"
name="doit"><div style="display:none;"><input type="hidden"
value="5de6bf73-616e-45b8-95e2-751ac1f64716" name="_formkey"><input
type="hidden" value="default" name="_formname"></div></form>
If I use the _value parameter instead of the value parameter for test1 (as
I have been doing) then it throws
an error ticket because the handling of the _value parameter is not unicode
safe.
The distinction between value and _value is not entirely clear to me and I
suggest
that the first example in the INPUT section of the book should perhaps use
value instead of _value.
In any case, I reckon it should be acceptable to use unicode with _value.
David
On Tuesday, September 24, 2013 11:36:26 AM UTC+10, Massimo Di Pierro wrote:
>
> I think we need to see the source code
>
> On Monday, 23 September 2013 19:09:32 UTC-5, David Austin wrote:
>>
>>
>>
>> On Tuesday, September 24, 2013 4:46:13 AM UTC+10, Massimo Di Pierro wrote:
>>>
>>> What is the code that generates this:
>>>
>>> <FONT FACE="Arial, serif">
>>>
>>> certainly there is no font tag anywhere in web2py. It was deprecated in
>>> HTML years ago.
>>>
>>
>>
>> Hi Massimo,
>>
>> I believe it comes from Microsoft Word. But the important thing is that
>>
>> <FONT FACE="Arial, serif">...
>>
>> is the value for the text field. And that value also contains UTF-8
>> characters.
>>
>> David
>>
>>
>>
>>>
>>> On Monday, 23 September 2013 09:00:28 UTC-5, David Austin wrote:
>>>>
>>>>
>>>> Hi All,
>>>>
>>>> I'm seeing a number of error tickets generated in the guts of web2py
>>>> stemming from a form.accepts() call.
>>>>
>>>>
>>>> File "xxxx/web2py/gluon/html.py", line 856, in _traverse
>>>>
>>>> self._postprocessing()
>>>> File "xxxxx/web2py/gluon/html.py", line 1774, in _postprocessing
>>>> _value = str(self['_value'])
>>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in
>>>> position 55: ordinal not in range(128)
>>>>
>>>>
>>>> The character in question appears to be a UTF-8 ellipsis (...).
>>>>
>>>> I thought that this may have been a browser issue - but I think now
>>>> it's just a web2py problem with text INPUTs containing
>>>> "interesting" characters - even in the values. The generated HTML
>>>> looks like:
>>>>
>>>> <input id="word_name" type="text" value="<FONT FACE="Arial,
>>>> serif"><FONT SIZE=2>as/so far as … is/are concerned</font></font>" name
>>>> ="name">
>>>>
>>>> which seems to have two issues - the double quotes in the value are not
>>>> escaped and the ellipsis (probably
>>>> ok HTML) is then going to generate the ticket I'm seeing at
>>>> str(self['_value']).
>>>>
>>>> David
>>>>
>>>>
--
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/groups/opt_out.