Go to Google Groups Home    pylons-discuss
Re: How do I set my form to be a unicode string?

Walter Cruz <walter....@gmail.com>

Well, I asked before search the in the list archives!

What I needed:

    tmpl_options['mako.input_encoding'] = 'UTF-8'
    tmpl_options['mako.output_encoding'] = 'UTF-8'
    tmpl_options['mako.default_filters'] = ['decode.utf8']
    request_settings = dict(charset='utf-8', errors='replace')
    return pylons.config.Config(tmpl_options, map,
paths,request_settings=request_settings)

In environment.py

I changed my formencode validator to: UnicodeString and now it's ok.

But I'm with a doubt:

Even with this, in my templates I've to use:

${h.link_to(u"Nova citação", h.url(action="new"))}

(Note the u before "Nova citação").

How can I configure this to avoid to say that this is string is unicode?

[]'s
- Walter

On 7/1/07, Christoph Haas <em...@christoph-haas.de> wrote:

> On Sat, Jun 30, 2007 at 11:55:25AM -0300, Walter Cruz wrote:
> > I'm getting this error:

> > <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode
> > byte 0xc3 in position 79: ordinal not in range(128) the form was
> > passed in as an encoded string, but some data or error messages were
> > unicode strings; the form should be passed in as a unicode string

> Depends on where that error occurs. Can you post a complete traceback?

> > How do I set the form to be unicode?

> Use the

> # -*- coding: utf-8 -*-

> preamble in the first line of your templates.

>  Christoph