From 8bb9cecfc0a2f11aeb2132c12876720033670bc7 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Dec 2020 16:08:06 +0200 Subject: [PATCH] Explanation comment on try/except --- EDMC.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/EDMC.py b/EDMC.py index 9552fa4c..04701313 100755 --- a/EDMC.py +++ b/EDMC.py @@ -173,6 +173,11 @@ sys.path: {sys.path}''' if args.j: logger.debug('Import and collate from JSON dump') # Import and collate from JSON dump + # + # Try twice, once with the system locale and once enforcing utf-8. If the file was made on the current + # system, chances are its the current locale, and not utf-8. Otherwise if it was copied, its probably + # utf8. Either way, try the system FIRST because reading something like cp1251 in UTF-8 results in garbage + # but the reverse results in an exception. try: data = json.load(open(args.j)) except UnicodeDecodeError: