try:
parser.title = title.encode('ascii')
except UnicodeEncodeError:
- parser.charset = DEFAULT_CHARSET
- parser.title = title.encode(DEFAULT_CHARSET)
+ try:
+ parser.title = title.encode(DEFAULT_CHARSET)
+ except UnicodeEncodeError:
+ parser.title = title.encode(universal_charset)
+ parser.charset = universal_charset
+ else:
+ parser.charset = DEFAULT_CHARSET
+ else:
+ parser.charset = 'ascii'
converted_title = title = parser.title
if title and (not parser.charset):