hgext/convert/common.py
changeset 5287 c6f932d3e0f6
parent 5172 6b4c332f241b
child 5352 f0931c0240b4
equal deleted inserted replaced
5286:cbec83d9b0b4 5287:c6f932d3e0f6
    73 
    73 
    74     def recode(self, s, encoding=None):
    74     def recode(self, s, encoding=None):
    75         if not encoding:
    75         if not encoding:
    76             encoding = self.encoding or 'utf-8'
    76             encoding = self.encoding or 'utf-8'
    77 
    77 
       
    78         if isinstance(s, unicode):
       
    79             return s.encode("utf-8")
    78         try:
    80         try:
    79             return s.decode(encoding).encode("utf-8")
    81             return s.decode(encoding).encode("utf-8")
    80         except:
    82         except:
    81             try:
    83             try:
    82                 return s.decode("latin-1").encode("utf-8")
    84                 return s.decode("latin-1").encode("utf-8")