##// END OF EJS Templates
respect encoding of display data from urls
MinRK -
Show More
@@ -268,6 +268,16 b' class DisplayObject(object):'
268 import urllib2
268 import urllib2
269 response = urllib2.urlopen(self.url)
269 response = urllib2.urlopen(self.url)
270 self.data = response.read()
270 self.data = response.read()
271 # extract encoding from header, if there is one:
272 encoding = None
273 for sub in response.headers['content-type'].split(';'):
274 sub = sub.strip()
275 if sub.startswith('charset'):
276 encoding = sub.split('=')[-1].strip()
277 break
278 # decode data, if an encoding was specified
279 if encoding:
280 self.data = self.data.decode(encoding, 'replace')
271 except:
281 except:
272 self.data = None
282 self.data = None
273
283
General Comments 0
You need to be logged in to leave comments. Login now