# HG changeset patch # User Matt Mackall # Date 1426530157 18000 # Node ID 7d5f935bd705978e45783a51092e64da2fa34646 # Parent 348492ba632a90fc3b901b3e13b08820a7d2c7d4 crecord: use encoding.ucolwidth diff -r 348492ba632a -r 7d5f935bd705 mercurial/crecord.py --- 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,