Show More
@@ -255,40 +255,17 b" if sys.platform == 'darwin':" | |||
|
255 | 255 | except UnicodeDecodeError: |
|
256 | 256 | # OS X percent-encodes any bytes that aren't valid utf-8 |
|
257 | 257 | s = '' |
|
258 |
|
|
|
259 |
l = |
|
|
260 |
|
|
|
261 |
|
|
|
262 | if l and o < 128 or o >= 192: | |
|
263 | # we want a continuation byte, but didn't get one | |
|
264 | s += ''.join(["%%%02X" % ord(x) for x in g]) | |
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 | # ascii | |
|
269 | s += c | |
|
270 | elif l == 0 and 194 <= o < 245: | |
|
271 | # valid leading bytes | |
|
272 | if o < 224: | |
|
273 | l = 1 | |
|
274 | elif o < 240: | |
|
275 | l = 2 | |
|
276 | else: | |
|
277 | l = 3 | |
|
278 | g = c | |
|
279 | elif l > 0 and 128 <= o < 192: | |
|
280 | # valid continuations | |
|
281 | g += c | |
|
282 | l -= 1 | |
|
283 | if not l: | |
|
284 | s += g | |
|
285 | g = '' | |
|
286 | else: | |
|
287 | # invalid | |
|
288 | s += "%%%02X" % o | |
|
258 | pos = 0 | |
|
259 | l = len(s) | |
|
260 | while pos < l: | |
|
261 | try: | |
|
262 | c = encoding.getutf8char(path, pos) | |
|
263 | pos += len(c) | |
|
264 | except ValueError: | |
|
265 | c = '%%%%02X' % path[pos] | |
|
266 | pos += 1 | |
|
267 | s += c | |
|
289 | 268 | |
|
290 | # any remaining partial characters | |
|
291 | s += ''.join(["%%%02X" % ord(x) for x in g]) | |
|
292 | 269 | u = s.decode('utf-8') |
|
293 | 270 | |
|
294 | 271 | # Decompose then lowercase (HFS+ technote specifies lower) |
General Comments 0
You need to be logged in to leave comments.
Login now