1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-13 16:08:29 +00:00

Improve windows lookalike characters

This commit is contained in:
Zezombye 2025-08-12 06:56:05 +02:00 committed by GitHub
parent b7de89c910
commit 3665d8823d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -639,8 +639,18 @@ def replace_insane(char):
elif not restricted and char == '\n':
return '\0 '
elif is_id is NO_DEFAULT and not restricted and char in '"*:<>?|/\\':
# Replace with their full-width unicode counterparts
return {'/': '\u29F8', '\\': '\u29f9'}.get(char, chr(ord(char) + 0xfee0))
# Replace with lookalike characters
return {
'"': '\u2033',
'*': '\uA60E',
':': '\u0589',
'<': '\u227A',
'>': '\u227B',
'?': '\uFF1F',
'|': '\u01C0',
'/': '\u29F8',
'\\': '\u29f9',
}[char]
elif char == '?' or ord(char) < 32 or ord(char) == 127:
return ''
elif char == '"':