equal
deleted
inserted
replaced
146 wide = "WFA" |
146 wide = "WFA" |
147 w = unicodedata.east_asian_width |
147 w = unicodedata.east_asian_width |
148 return sum([w(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): |
|
152 "best-effort encoding-aware case-folding of local string s" |
|
153 try: |
|
154 if isinstance(s, localstr): |
|
155 u = s._utf8.decode("utf-8") |
|
156 else: |
|
157 u = s.decode(encoding, encodingmode) |
|
158 |
|
159 lu = u.lower() |
|
160 if u == lu: |
|
161 return s # preserve localstring |
|
162 return lu.encode(encoding) |
|
163 except UnicodeError: |
|
164 return s.lower() # we don't know how to fold this except in ASCII |