equal
deleted
inserted
replaced
244 |
244 |
245 def recode(self, s, encoding=None): |
245 def recode(self, s, encoding=None): |
246 if not encoding: |
246 if not encoding: |
247 encoding = self.encoding or b'utf-8' |
247 encoding = self.encoding or b'utf-8' |
248 |
248 |
249 if isinstance(s, pycompat.unicode): |
249 if isinstance(s, str): |
250 return s.encode("utf-8") |
250 return s.encode("utf-8") |
251 try: |
251 try: |
252 return s.decode(pycompat.sysstr(encoding)).encode("utf-8") |
252 return s.decode(pycompat.sysstr(encoding)).encode("utf-8") |
253 except UnicodeError: |
253 except UnicodeError: |
254 try: |
254 try: |