Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 22425:6fd944c204a9
encoding: handle empty string in toutf8
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 15 Sep 2014 13:12:20 -0500 |
parents | b515c3a63e96 |
children | f6b533e64ed6 |
comparison
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 |