Thanks TheBoff,

I tried all of this but unfortunately the problem persists.
Error message:

  File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 10-12:
invalid d
ata



On 20 nov, 18:57, TheBoff <[EMAIL PROTECTED]> wrote:
> Or, if the template is xhtml you could try this:
>
> <?xml version="1.0" encoding="utf-8"?>
>
> At the very top of the file.
>
> On Nov 20, 9:54 pm, TheBoff <[EMAIL PROTECTED]> wrote:
>
> > I had a problem a bit like this once.
>
> > One way to solve it might be to put a meta tag like this into the head
> > section of your template
> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
> > although you do already have that inn your header, which should take
> > precendence.
>
> > Another thing to try is the html language attribute
> > <html lang="es">.
>
> > If none of these work, you could try doing a find and replace on the
> > document for special language characters, and replacing them with
> > their (x)html 
> > escapes:http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_re...
>
> > Hope this helps,
>
> > Colin
>
> > On Nov 20, 1:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > I wrote a simple script to scrap news from yahoo and display them in
> > > my site.
> > > The problem is that the news are in spanish, and the text I get
> > > doesn't show properly the spanish accents.
> > > I guess it has something to do with encoding formats but I'm
> > > completely ignorant of this matter.
> > > In webpy docs I found the utf8 function, but it doesn't seem to
> > > work...
>
> > > I'd like to know if this problem is webpy related or not. This is the
> > > code (webpy 0.3):
>
> > > class news(app.page):
> > >     def GET(self):
> > >         web.header('Content-Type', 'text/html; charset=UTF-8')
> > >         from google.appengine.api import urlfetch
> > >         from BeautifulSoup import BeautifulSoup
> > >         from google.appengine.api import mail
>
> > >         page = urlfetch.fetch("http://ar.news.yahoo.com";, headers=
> > > {'Content-Type': 'text/html; charset=UTF-8'})
> > >         soup = BeautifulSoup(page.content)
> > >         s=[]
> > >         block = soup('ul',{"class":"headlines"})
> > >         for i in block:
> > >             s.append(str(i))
> > >         res = ''.join(s)
> > >         #res = utils.utf8(res)
> > >         res = res.replace('"/', '"http://ar.news.yahoo.com/')
> > >         return utils.utf8(res)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to