On Sat, Jan 23, 2010 at 10:37 PM, David Shieh <[email protected]> wrote: > Hey guys, > I faced a unicode problem now, in forms.py, I wrote a form like this: > ---------------------------------------------------------------------- > #-*-coding=utf-8-*- > usernameValidator = form.regexp(r".{3,15}$", "Please input username") > emailValidator = form.regexp(r"....@.*", u"请输入合法的Email地址") > urlValidator = form.regexp(r"http://.*", u"请输入合法的URL地址") > commentForm = form.Form( > form.Textbox('name', usernameValidator), > form.Textbox('email', emailValidator), > form.Textbox('url'), > form.Textarea('comment', form.notnull), > form.Textbox('captcha', captchaValidator, > description="Captcha Code"), > ) > ---------------------------------------------------------------------- > The charactors in Validadors are Chinese, and I used form in template > jinja2 by using > {{ f.email.render() }}. > The problem happened when I submit empty form, and I've got an error > like this: > <type 'exceptions.UnicodeDecodeError'> at /entry/how-to-create-rss-2- > yourself/ > ('ascii', '<input type="text" name="email" id="email" /><strong > class="wrong">\xe8\xaf\xb7\xe8\xbe > \x93\xe5\x85\xa5\xe5\x90\x88\xe6\xb3\x95\xe7\x9a\x84Email\xe5\x9c > \xb0\xe5\x9d\x80</strong>', 67, 68, 'ordinal not in range(128)') > > I know it's charset's problem, and question is, how can I fix it, I > even tried to encode and decode the error message, but it didn't help. > Guys, please help me with this, thanks !
Can you share the traceback of the exception? -- You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en.
