Private GIT

Skip to content
Snippets Groups Projects
Commit ed143d5c authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

Text factory decoding order change - Fixes SiCKRAGETV/sickrage-issues#2319

parent fdd4ec6b
Branches
Tags
No related merge requests found
...@@ -229,19 +229,23 @@ class DBConnection(object): ...@@ -229,19 +229,23 @@ class DBConnection(object):
def _unicode_text_factory(self, x): def _unicode_text_factory(self, x):
try: try:
# Already unicode, empty string, or ascii
x = unicode(x) x = unicode(x)
except Exception: except Exception:
try: try:
x = unicode(x, sickbeard.SYS_ENCODING) # most common encoding from web
except Exception:
try:
x = unicode(x, 'utf-8') x = unicode(x, 'utf-8')
except Exception: except Exception:
try: try:
# most common from web if utf-8 fails
x = unicode(x, 'latin-1') x = unicode(x, 'latin-1')
except Exception: except Exception:
try: try:
# Chardet can be wrong, so try it before ignoring # try system encoding before trusting chardet
x = unicode(x, sickbeard.SYS_ENCODING)
except Exception:
try:
# Chardet can be wrong, so try it last before ignoring
x = unicode(x, chardet.detect(x).get('encoding')) x = unicode(x, chardet.detect(x).get('encoding'))
except Exception: except Exception:
x = unicode(x, sickbeard.SYS_ENCODING, errors="ignore") x = unicode(x, sickbeard.SYS_ENCODING, errors="ignore")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment