from bs4 import BeautifulSoup
from .bkmk_ph_util import HTMLParser
+universal_charset = "utf-8"
DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic
def _parse_html(html_text, charset):
meta_charset = _charset = meta_content.lower()
if title and (_charset or meta_charset):
- title = title.encode(_charset or meta_charset)
+ try:
+ title = title.encode(_charset or meta_charset)
+ except LookupError:
+ title = title.encode(universal_charset)
+ _charset = universal_charset
meta = head.find(_find_refresh, recursive=False)
if meta: