equal
deleted
inserted
replaced
174 def normcase(path): |
174 def normcase(path): |
175 try: |
175 try: |
176 u = path.decode('utf-8') |
176 u = path.decode('utf-8') |
177 except UnicodeDecodeError: |
177 except UnicodeDecodeError: |
178 # percent-encode any characters that don't round-trip |
178 # percent-encode any characters that don't round-trip |
179 p2 = path.decode('utf-8', 'replace').encode('utf-8') |
179 p2 = path.decode('utf-8', 'ignore').encode('utf-8') |
180 s = "" |
180 s = "" |
181 for a, b in zip(path, p2): |
181 pos = 0 |
182 if a != b: |
182 for c in path: |
183 s += "%%%02X" % ord(a) |
183 if p2[pos:pos + 1] == c: |
|
184 s += c |
|
185 pos += 1 |
184 else: |
186 else: |
185 s += a |
187 s += "%%%02X" % ord(c) |
186 u = s.decode('utf-8') |
188 u = s.decode('utf-8') |
187 |
189 |
188 # Decompose then lowercase (HFS+ technote specifies lower) |
190 # Decompose then lowercase (HFS+ technote specifies lower) |
189 return unicodedata.normalize('NFD', u).lower().encode('utf-8') |
191 return unicodedata.normalize('NFD', u).lower().encode('utf-8') |
190 |
192 |