"""
-import os
+import sys, os
from m_lib.net.www.html import HTMLParser
from bkmk_objects import Folder, Bookmark, Ruler
dump_names = debug
+DEFAULT_CHARSET = None
+
class BkmkParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
def handle_data(self, data):
if data:
- if self.charset:
- data = unicode(data, self.charset).encode()
+ if DEFAULT_CHARSET:
+ data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "replace")
self.accumulator += data
self.charset = content.split('=')[1]
except IndexError:
pass
+ else:
+ global DEFAULT_CHARSET
+ DEFAULT_CHARSET = sys.getdefaultencoding()
def start_title(self, attrs):