Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How do I set my form to be a unicode string?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Walter Cruz  
View profile   Translate to Translated (View Original)
 More options 30 June 2007, 15:55
From: "Walter Cruz" <walter....@gmail.com>
Date: Sat, 30 Jun 2007 11:55:25 -0300
Local: Sat 30 June 2007 15:55
Subject: How do I set my form to be a unicode string?
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

How do I set the form to be unicode?

[]'s
- Walter


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christoph Haas  
View profile   Translate to Translated (View Original)
 More options 1 July 2007, 08:46
From: Christoph Haas <em...@christoph-haas.de>
Date: Sun, 1 Jul 2007 09:46:07 +0200
Local: Sun 1 July 2007 08:46
Subject: Re: How do I set my form to be a unicode string?

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walter Cruz  
View profile   Translate to Translated (View Original)
 More options 1 July 2007, 15:27
From: "Walter Cruz" <walter....@gmail.com>
Date: Sun, 1 Jul 2007 11:27:38 -0300
Local: Sun 1 July 2007 15:27
Subject: Re: How do I set my form to be a unicode string?
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:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christoph Haas  
View profile   Translate to Translated (View Original)
 More options 1 July 2007, 16:05
From: Christoph Haas <em...@christoph-haas.de>
Date: Sun, 1 Jul 2007 17:05:13 +0200
Local: Sun 1 July 2007 16:05
Subject: Re: How do I set my form to be a unicode string?

On Sun, Jul 01, 2007 at 11:27:38AM -0300, Walter Cruz wrote:
> Well, I asked before search the in the list archives!

Sorry, no. If you like to continue the topic you brought up with another
thread then please use the other thread. I didn't follow the other
thread. If you start a new thread then I recommend you put all necessary
information into it.

> 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)

You shouldn't need the mako.default_filters setting. IMHO it slows done
things unnecessarily. The request_settings parameter does the work
already.

> In environment.py

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

Very good.

> 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?

You can't. A string contains 7-bit character in Python. So if you use
anything besides 7-bit ASCII you need to use unicode objects. Generally
(not only with Pylons) it's wise to always use Unicode internally and
just convert them on input/output. Trust me - it will save you time and
hassle.

Kindly
 Christoph


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google