]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/parse_html.py
Charset was guessed if it is not from META and not from HTTP.
[bookmarks_db.git] / Robots / parse_html.py
index b2ef61b53ce348ba73851d779942053775526ce6..ec93ea5acb0903e9557bc370559a0a0ebee4dd6e 100755 (executable)
@@ -59,7 +59,7 @@ def parse_html(filename, charset=None, log=None):
 
    charsets = [universal_charset, DEFAULT_CHARSET]
    if charset:
-      charset = charset.lower()
+      charset = charset.lower().replace("windows-", "cp")
       if charset not in charsets:
          charsets.insert(0, charset)
 
@@ -84,13 +84,13 @@ def parse_html(filename, charset=None, log=None):
          parser.charset = DEFAULT_CHARSET
 
    if parser.charset:
-      parser.charset = parser.charset.replace("windows-", "cp").lower()
+      parser.charset = parser.charset.lower().replace("windows-", "cp")
 
    if parser.charset and (parser.charset <> universal_charset):
       try:
          if parser.meta_charset:
             if log: log("   META charset   : %s" % parser.charset)
-         else:
+         elif (not charset) or charset <> parser.charset:
             if log: log("   guessed charset: %s" % parser.charset)
          if log: log("   current charset: %s" % universal_charset)
          if log: log("   title          : %s" % title)