mercurial/crecord.py
changeset 24315 7d5f935bd705
parent 24314 348492ba632a
child 24316 d61aa383e2e5
--- a/mercurial/crecord.py	Mon Mar 16 12:58:06 2015 -0500
+++ b/mercurial/crecord.py	Mon Mar 16 13:22:37 2015 -0500
@@ -877,13 +877,8 @@
         width = self.xscreensize
         # turn tabs into spaces
         instr = instr.expandtabs(4)
-        try:
-            strlen = len(unicode(encoding.fromlocal(instr), code))
-        except Exception:
-            # if text is not utf8, then assume an 8-bit single-byte encoding.
-            strlen = len(instr)
-
-        numspaces = (width - ((strlen + xstart) % width) - 1)
+        strwidth = encoding.ucolwidth(instr)
+        numspaces = (width - ((strwidth + xstart) % width) - 1)
         return instr + " " * numspaces + "\n"
 
     def printstring(self, window, text, fgcolor=None, bgcolor=None, pair=None,