Loading ...
Sorry, an error occurred while loading the content.

4955Re: [Cheetahtemplate-discuss] Non-ASCII character

Expand Messages
  • R. Tyler Croy
    Apr 9, 2011
    • 0 Attachment
      On Sat, 09 Apr 2011, Pasithee Jupiter wrote:

      > Hi all
      >
      > 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 = ('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>', 107216,
      > 107217, 'ordinal not in range(128)')
      > encoding = 'ascii'
      > end = 107217
      > message = ''
      > object = 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>'
      > reason = 'ordinal not in range(128)'
      > start = 107216
      >
      >
      > In my Python script I call a json url and get back a bunch of data:
      >
      > resultlist = 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?

      >
      > The url is the following:
      > http://taginfo.openstreetmap.de/api/2/search/values?q=restaurant&sortname=count_all&sortorder=desc
      >
      > As you can see when you open the url, the response includes a lot of special
      > characters
      > In my template I try to display these data which are in the resultlist
      > variable
      >
      > #for $result in $resultlist
      >
      > <tr>
      >
      > <td>$result['count']</td>
      >
      > <td>$result['key']</td>
      >
      > </tr>
      >
      > #end for
      >
      >
      > But it does not work.
      >
      >
      > Any hint?
      >
      > Thanks a lot
      >
      > 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
      > Cheetahtemplate-discuss@...
      > 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
    • Show all 3 messages in this topic