Show More
@@ -148,3 +148,17 def colwidth(s): | |||||
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 |
General Comments 0
You need to be logged in to leave comments.
Login now