Re: Non-ASCII character

"R. Tyler Croy" <[email protected]> Sat, 9 Apr 2011 10:56:14 -0700
Newsgroups gmane.comp.python.cheetah
Message-ID <20110409175613.GA15235@kiwi>
--===============1286986332098330439==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="C7zPtVaVf+AK4Oqc"
Content-Disposition: inline


--C7zPtVaVf+AK4Oqc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


On Sat, 09 Apr 2011, Pasithee Jupiter wrote:

> Hi all
>=20
> I have the following error:
> *<type 'exceptions.UnicodeEncodeError'>*: 'ascii' codec can't encode
> character u'\xe4' in position 107216: ordinal not in range(128)
>       args =3D ('ascii', u'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
> Tra...</tbody>\n\t\t\t</table>\n\t\t</footer>\n\t</body>\n</html>', 10721=
6,
> 107217, 'ordinal not in range(128)')
>       encoding =3D 'ascii'
>       end =3D 107217
>       message =3D ''
>       object =3D u'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Tra...</t=
body>
> \n\t\t\t</table>\n\t\t</footer>\n\t</body>\n</html>'
>       reason =3D 'ordinal not in range(128)'
>       start =3D 107216
>=20
>=20
> In my Python script I call a json url and get back a bunch of data:
>=20
> resultlist =3D simplejson.load(urllib.urlopen(urlvalue))


What kind of object are you getting back from this simplejson call? If you'=
re
not getting a proper unicode object, you may need to do some decoding first=
 to
make the string play nicely with the rest of the template.


That said, what version of Cheetah are you running?

>=20
> The url is the following:
> http://taginfo.openstreetmap.de/api/2/search/values?q=3Drestaurant&sortna=
me=3Dcount_all&sortorder=3Ddesc
>=20
> As you can see when you open the url, the response includes a lot of spec=
ial
> characters
> In my template I try to display these data which are in the resultlist
> variable
>=20
> #for $result in $resultlist
>=20
> <tr>
>=20
> <td>$result['count']</td>
>=20
> <td>$result['key']</td>
>=20
> </tr>
>=20
> #end for
>=20
>=20
> But it does not work.
>=20
>=20
> Any hint?
>=20
> Thanks a lot
>=20
> Pasithee

> -------------------------------------------------------------------------=
-----
> Xperia(TM) PLAY
> It's a major breakthrough. An authentic gaming
> smartphone on the nation's most reliable network.
> And it wants your games.
> http://p.sf.net/sfu/verizon-sfdev

> _______________________________________________
> Cheetahtemplate-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

- R. Tyler Croy
--------------------------------------
    Code: http://github.com/rtyler
 Chatter: http://identi.ca/agentdero
          http://twitter.com/agentdero

--C7zPtVaVf+AK4Oqc
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iEYEARECAAYFAk2gnb0ACgkQFCbH3D9R4W/lzQCcDhPUApquFkFWSgUmXIk33tuL
+fYAn0R0jcDMhkWeRkh4Pc0yF/HDVx53
=Mk53
-----END PGP SIGNATURE-----

--C7zPtVaVf+AK4Oqc--


--===============1286986332098330439==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
--===============1286986332098330439==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Cheetahtemplate-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

--===============1286986332098330439==--