aliva / SubtitleFixer

fixes persian subtitles encoding
subtitlefixer.ir
59 stars 8 forks source link

fix guess encoding #7

Closed aliva closed 11 years ago

aliva commented 11 years ago

روش فعلی حدس انکودینگ فایل خطا دارد باید از روش بهتری استفاده شود

درجه خطا پایین است، تا به حال فقط یک گزارش خط داشتم

الان از این دو قسمت استفاده می‌شود

    def is_utf8(self):
        assert isinstance(self.string, str), repr(self.string)
        if isinstance(self.string, unicode):
            return True

        try:
            self.string.decode('utf8', 'strict')
        except UnicodeError:
            return True

        return False
        if self.is_utf8():
            self.string = self.string.decode('windows-1256')
        else:
            self.string = self.string.decode('utf-8')
aliva commented 11 years ago

به نظر می‌رسد فایل‌هایی که مشکل داشتند از انکودینگ utf-16 استفاده می‌کردند.

aliva commented 11 years ago

مشکل برای فال‌هایی که تست می‌کردم حل شد