mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-04 15:12:23 -05: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)
|
||||
|
||||
try:
|
||||
return u_x.encode(sickbeard.SYS_ENCODING)
|
||||
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
|
||||
except:
|
||||
try:
|
||||
return u_x.encode(sickbeard.SYS_ENCODING, 'replace')
|
||||
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING)
|
||||
except:
|
||||
try:
|
||||
return u_x.encode('utf-8', 'replace')
|
||||
u_x_encoded = u_x.encode(sickbeard.SYS_ENCODING, 'replace')
|
||||
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):
|
||||
if not isinstance(x, (list, tuple)):
|
||||
|
@ -213,10 +213,7 @@ class WebHandler(BaseHandler):
|
||||
def async_done(self, results):
|
||||
try:
|
||||
if results is not None:
|
||||
try:
|
||||
results = ek.ss(results).encode('utf-8', 'xmlcharrefreplace')
|
||||
except:
|
||||
results = str(results)
|
||||
results = ek.ss(results)
|
||||
|
||||
self.finish(results)
|
||||
except:
|
||||
|
@ -15,14 +15,13 @@ DEBUG = VERBOSE = False
|
||||
|
||||
class EncodingTests(unittest.TestCase):
|
||||
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:
|
||||
try:
|
||||
print ek.ss(s)
|
||||
print unicode(s).decode('UTF-8')
|
||||
print 'Encoded: ' + ek.ss(s)
|
||||
except Exception, e:
|
||||
print ex(e)
|
||||
ex(e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print "=================="
|
||||
|
Loading…
Reference in New Issue
Block a user