dump_names = debug
-DEFAULT_CHARSET = None
+try:
+ from m_lib.defenc import default_encoding as DEFAULT_CHARSET
+except ImportError:
+ DEFAULT_CHARSET = None
class BkmkParser(HTMLParser):
def __init__(self):
self.urls = 0
self.objects = 0
- self.charset = ""
+ self.charset = None
self.recode = None
def handle_data(self, data):
if data:
- if DEFAULT_CHARSET:
+ if self.charset and DEFAULT_CHARSET:
data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "xmlcharrefreplace")
self.accumulator += data
self.charset = content.split('=')[1]
except IndexError:
pass
- else:
- global DEFAULT_CHARSET
- DEFAULT_CHARSET = sys.getdefaultencoding()
- if DEFAULT_CHARSET == "ascii":
- try:
- import locale
- except ImportError:
- pass
- else:
- DEFAULT_CHARSET = locale.getpreferredencoding()
def start_title(self, attrs):
if DEFAULT_CHARSET: