Mercurial > hg > cc > cirrus_work
annotate bin/percent_encode.py @ 91:460f0599e8cd
mostly working, but need to reorder in case of cfid and friends
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Tue, 05 Sep 2023 17:32:46 +0100 |
| parents | 1daa8e444cfe |
| children |
| rev | line source |
|---|---|
|
85
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 '''Handle unquoting of non-UTF-8 bytes by %-encoding them''' |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 import codecs |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 def percent_encode(ude): |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 #print(ude.object,ude.object[ude.start:ude.end]) |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 return (''.join('%%%X'%c for c in ude.object[ude.start:ude.end]), |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 ude.end) |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 |
|
1daa8e444cfe
work-around for weird handling of %-encoding in Java impl. of SURT
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 codecs.register_error('percent',percent_encode) |
