add_surrogate bug fix

This commit is contained in:
Yusuf Usta 2021-11-06 14:47:46 +03:00 committed by GitHub
parent 2e1be01ad4
commit 2149ed07d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@ def add_surrogate(text):
# SMP -> Surrogate Pairs (Telegram offsets are calculated with these).
# See https://en.wikipedia.org/wiki/Plane_(Unicode)#Overview for more.
''.join(chr(y) for y in struct.unpack('<HH', x.encode('utf-16le')))
if (0x10000 <= ord(x) <= 0x10FFFF) else x for x in text
if (0x10000 <= ord(x) <= 0x10FFFF) else x for x in str(text)
)