From a394f04fc041e42c9b2551a19770dc6e56c047b2 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 29 Jan 2005 18:17:52 +0000 Subject: [PATCH] If sys.getdefaultencoding() returns "ascii" - use locale.getpreferredencoding() to get user's charset. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@50 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- bkmk_parser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bkmk_parser.py b/bkmk_parser.py index dfe7ce2..d436741 100755 --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -1,7 +1,7 @@ """ Parser for Netscape Navigator's and Mozilla's bookmarks.html - Written by BroytMann. Copyright (C) 1997-2004 PhiloSoft Design + Written by BroytMann. Copyright (C) 1997-2005 PhiloSoft Design """ @@ -70,6 +70,13 @@ class BkmkParser(HTMLParser): 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): -- 2.39.5