mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-02 16:09:24 +01:00
RSS: Another attempt at fixing encoding issues.
This commit is contained in:
parent
cdf97100f6
commit
933d4d3ffa
@ -150,14 +150,22 @@ class RSS(callbacks.Plugin):
|
|||||||
if headline[2]:
|
if headline[2]:
|
||||||
pubDate = ' [%s]' % (headline[2],)
|
pubDate = ' [%s]' % (headline[2],)
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
|
try:
|
||||||
|
import charade.universaldetector
|
||||||
|
u = charade.universaldetector.UniversalDetector()
|
||||||
|
u.feed(s)
|
||||||
|
u.close()
|
||||||
|
encoding = u.result['encoding']
|
||||||
|
except ImportError:
|
||||||
|
encoding = 'utf8'
|
||||||
if isinstance(headline[0], unicode):
|
if isinstance(headline[0], unicode):
|
||||||
newheadlines.append(format('%s %u%s',
|
newheadlines.append(format('%s %u%s',
|
||||||
headline[0].encode('utf-8','replace'),
|
headline[0].encode(encoding,'replace'),
|
||||||
link,
|
link,
|
||||||
pubDate))
|
pubDate))
|
||||||
else:
|
else:
|
||||||
newheadlines.append(format('%s %u%s',
|
newheadlines.append(format('%s %u%s',
|
||||||
headline[0].decode('utf-8','replace'),
|
headline[0]
|
||||||
link,
|
link,
|
||||||
pubDate))
|
pubDate))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user