equal
deleted
inserted
replaced
138 ambiguous = os.environ.get("HGENCODINGAMBIGUOUS", "narrow") |
138 ambiguous = os.environ.get("HGENCODINGAMBIGUOUS", "narrow") |
139 |
139 |
140 def colwidth(s): |
140 def colwidth(s): |
141 "Find the column width of a UTF-8 string for display" |
141 "Find the column width of a UTF-8 string for display" |
142 d = s.decode(encoding, 'replace') |
142 d = s.decode(encoding, 'replace') |
143 if hasattr(unicodedata, 'east_asian_width'): |
143 eaw = getattr(unicodedata, 'east_asian_width', None) |
|
144 if eaw is not None: |
144 wide = "WF" |
145 wide = "WF" |
145 if ambiguous == "wide": |
146 if ambiguous == "wide": |
146 wide = "WFA" |
147 wide = "WFA" |
147 w = unicodedata.east_asian_width |
148 return sum([eaw(c) in wide and 2 or 1 for c in d]) |
148 return sum([w(c) in wide and 2 or 1 for c in d]) |
|
149 return len(d) |
149 return len(d) |
150 |
150 |
151 def lower(s): |
151 def lower(s): |
152 "best-effort encoding-aware case-folding of local string s" |
152 "best-effort encoding-aware case-folding of local string s" |
153 try: |
153 try: |