Show More
@@ -138,17 +138,13 b' def fromlocal(s):' | |||
|
138 | 138 | except LookupError, k: |
|
139 | 139 | raise Abort(_("%s, please check your locale settings") % k) |
|
140 | 140 | |
|
141 | _colwidth = None | |
|
142 | 141 | def colwidth(s): |
|
143 |
|
|
|
144 | global _colwidth | |
|
145 | if _colwidth is None: | |
|
146 |
|
|
|
147 | _colwidth = lambda s: sum([unicodedata.east_asian_width(c) in 'WF' | |
|
148 | and 2 or 1 for c in s]) | |
|
149 | else: | |
|
150 | _colwidth = len | |
|
151 | return _colwidth(s.decode(_encoding, "replace")) | |
|
142 | "Find the column width of a UTF-8 string for display" | |
|
143 | d = s.decode(_encoding, 'replace') | |
|
144 | if hasattr(unicodedata, 'east_asian_width'): | |
|
145 | w = unicodedata.east_asian_width | |
|
146 | return sum([w(c) in 'WF' and 2 or 1 for c in d]) | |
|
147 | return len(d) | |
|
152 | 148 | |
|
153 | 149 | def version(): |
|
154 | 150 | """Return version information if available.""" |
General Comments 0
You need to be logged in to leave comments.
Login now