From 79bb3ba0053df10d79c527812b42cf6b454bba2c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Jan 2010 11:22:30 -0700 Subject: [PATCH] Fix #4683 (If comics.txt is UTF-8 with a byte order mark, the first comic is skipped) --- src/calibre/ebooks/comic/input.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/comic/input.py b/src/calibre/ebooks/comic/input.py index 122f61e45a..6fba918888 100755 --- a/src/calibre/ebooks/comic/input.py +++ b/src/calibre/ebooks/comic/input.py @@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en' Based on ideas from comiclrf created by FangornUK. ''' -import os, shutil, traceback, textwrap, time +import os, shutil, traceback, textwrap, time, codecs from ctypes import byref from Queue import Empty @@ -338,8 +338,9 @@ class ComicInput(InputFormatPlugin): if not os.path.exists('comics.txt'): raise ValueError('%s is not a valid comic collection' %stream.name) - for line in open('comics.txt', - 'rb').read().decode('utf-8').splitlines(): + raw = open('comics.txt', 'rb').read().decode('utf-8') + raw.lstrip(unicode(codecs.BOM_UTF8, "utf8" )) + for line in raw.splitlines(): line = line.strip() if not line: continue