mirror of
https://github.com/moparisthebest/SickRage
synced 2024-08-13 16:53:54 -04:00
Fixed issue #1024 - EncodingKludge issue identified and fixed
This commit is contained in:
parent
0494f6f76c
commit
92a554da99
@ -63,15 +63,20 @@ def ss(x):
|
|||||||
u_x = _toUnicode(x)
|
u_x = _toUnicode(x)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return u_x.encode(sickbeard.SYS_ENCODING)
|
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
return u_x.encode(sickbeard.SYS_ENCODING, 'replace')
|
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING)
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
return u_x.encode('utf-8', 'replace')
|
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'replace')
|
||||||
except:
|
except:
|
||||||
return x
|
try:
|
||||||
|
u_x_encoded = u_x.encode('utf-8', 'replace')
|
||||||
|
except:
|
||||||
|
u_x_encoded = x
|
||||||
|
|
||||||
|
return u_x_encoded
|
||||||
|
|
||||||
def fixListEncodings(x):
|
def fixListEncodings(x):
|
||||||
if not isinstance(x, (list, tuple)):
|
if not isinstance(x, (list, tuple)):
|
||||||
|
@ -213,10 +213,7 @@ class WebHandler(BaseHandler):
|
|||||||
def async_done(self, results):
|
def async_done(self, results):
|
||||||
try:
|
try:
|
||||||
if results is not None:
|
if results is not None:
|
||||||
try:
|
results = ek.ss(results)
|
||||||
results = ek.ss(results).encode('utf-8', 'xmlcharrefreplace')
|
|
||||||
except:
|
|
||||||
results = str(results)
|
|
||||||
|
|
||||||
self.finish(results)
|
self.finish(results)
|
||||||
except:
|
except:
|
||||||
|
@ -15,14 +15,13 @@ DEBUG = VERBOSE = False
|
|||||||
|
|
||||||
class EncodingTests(unittest.TestCase):
|
class EncodingTests(unittest.TestCase):
|
||||||
def test_encoding(self):
|
def test_encoding(self):
|
||||||
strings = [u'הערוץ הראשון', 'Les Enfants De La Télé', u'\x89']
|
strings = [u'Les Enfants De La Télé']
|
||||||
|
|
||||||
for s in strings:
|
for s in strings:
|
||||||
try:
|
try:
|
||||||
print ek.ss(s)
|
print 'Encoded: ' + ek.ss(s)
|
||||||
print unicode(s).decode('UTF-8')
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print ex(e)
|
ex(e)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print "=================="
|
print "=================="
|
||||||
|
Loading…
Reference in New Issue
Block a user