Merge branch 'master' into testing

This commit is contained in:
Valentin Lorentz 2012-02-18 13:01:06 +01:00
commit 68bcffb57b
1 changed files with 6 additions and 4 deletions

View File

@ -291,10 +291,12 @@ class RSS(callbacks.Plugin):
toText = utils.web.htmlToText
if 'encoding' in feed:
def conv(s):
try:
return toText(s).strip().encode(feed['encoding'],'replace')
except UnicodeEncodeError:
return toText(s.encode('utf-8', 'ignore')).strip()
# encode() first so there implicit encoding doesn't happen in
# other functions when unicode and bytestring objects are used
# together
s = s.encode(feed['encoding'], 'replace')
s = toText(s).strip()
return s
return conv
else:
return lambda s: toText(s).strip()