From: Oleg Broytman Date: Mon, 3 Mar 2008 17:50:06 +0000 (+0000) Subject: Charset was guessed if it is not from META and not from HTTP. X-Git-Tag: v4.5.3~187 X-Git-Url: https://git.phdru.name/?p=bookmarks_db.git;a=commitdiff_plain;h=3cb1b83ad134cc67669ff52cfed5662c80bbade4 Charset was guessed if it is not from META and not from HTTP. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@189 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- diff --git a/Robots/parse_html.py b/Robots/parse_html.py index b2ef61b..ec93ea5 100755 --- a/Robots/parse_html.py +++ b/Robots/parse_html.py @@ -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)