mercurial/encoding.py
changeset 22425 6fd944c204a9
parent 21861 b515c3a63e96
child 22426 f6b533e64ed6
equal deleted inserted replaced
22424:1f72226064b8 22425:6fd944c204a9
   334 
   334 
   335     if isinstance(s, localstr):
   335     if isinstance(s, localstr):
   336         return s._utf8
   336         return s._utf8
   337 
   337 
   338     try:
   338     try:
   339         if s.decode('utf-8'):
   339         s.decode('utf-8')
   340             return s
   340         return s
   341     except UnicodeDecodeError:
   341     except UnicodeDecodeError:
   342         # surrogate-encode any characters that don't round-trip
   342         # surrogate-encode any characters that don't round-trip
   343         s2 = s.decode('utf-8', 'ignore').encode('utf-8')
   343         s2 = s.decode('utf-8', 'ignore').encode('utf-8')
   344         r = ""
   344         r = ""
   345         pos = 0
   345         pos = 0