Skip to content

Commit

Permalink
[compat] Work around in case folding for narrow Python build
Browse files Browse the repository at this point in the history
Resolves ytdl-org#31324.
  • Loading branch information
dirkf authored Nov 2, 2022
1 parent 087ddc2 commit c4b19a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion youtube_dl/casefold.py
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,15 @@
1E921; C; 1E943; # ADLAM CAPITAL LETTER SHA
'''

_parse_unichr = lambda s: compat_chr(int(s, 16))

def _parse_unichr(s):
s = int(s, 16)
try:
return compat_chr(s)
except ValueError:
# work around "unichr() arg not in range(0x10000) (narrow Python build)"
return ('\\U%08x' % s).decode('unicode-escape')


_map = dict(
(_parse_unichr(from_), ''.join(map(_parse_unichr, to_.split(' '))))
Expand Down

0 comments on commit c4b19a8

Please sign in to comment.