On 7/30/07, Walter Rodrigo de Sá Cruz <[EMAIL PROTECTED]> wrote:
>
> Hi al.. I have a doubt about toscawidgtes regarding utf-8!
>
> A example:
>
> If i run the wsgi app in
> http://trac.turbogears.org/browser/projects/ToscaWidgets/trunk/examples/wsgi_app.py
> it works fine.
>
> But if I change the Person name to 'João', it throws me a
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> 2: ordinal not in range(128).
If you pass in a "byte string" (ie, standard "") to ToscaWidgets, and
it wants to convert it to a "Unicode string" (ie, u""), it is going to
assume it is in the system's site default encoding.
However, if you have a "Unicode string", then there is no problem - it
is used correctly.
If you want to verify this, you can use:
name = u'Jo\xe3o'
You can also read PEP 263 on how you can tell Python how to treat
string literals in the file as something other can ASCII.
(Changing sitecustomize.py is almost never the right thing to do.)
Neil
--
Neil Blakey-Milner
http://nxsy.org/
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---