--- a/mercurial/util.py Wed Jan 21 20:29:47 2009 +0900
+++ b/mercurial/util.py Fri Jan 23 14:51:09 2009 -0600
@@ -138,17 +138,13 @@
except LookupError, k:
raise Abort(_("%s, please check your locale settings") % k)
-_colwidth = None
def colwidth(s):
- """Find the column width of string to display."""
- global _colwidth
- if _colwidth is None:
- if hasattr(unicodedata, 'east_asian_width'):
- _colwidth = lambda s: sum([unicodedata.east_asian_width(c) in 'WF'
- and 2 or 1 for c in s])
- else:
- _colwidth = len
- return _colwidth(s.decode(_encoding, "replace"))
+ "Find the column width of a UTF-8 string for display"
+ d = s.decode(_encoding, 'replace')
+ if hasattr(unicodedata, 'east_asian_width'):
+ w = unicodedata.east_asian_width
+ return sum([w(c) in 'WF' and 2 or 1 for c in d])
+ return len(d)
def version():
"""Return version information if available."""