I have a simple script in python copy text and paste another place i wanna Prevent Copy if a text have fancy character like bottom
Hello ℌ
Must Skip Emojies and legal characters (Arabic & English)
How can it possible as easiest way
I have a simple script in python copy text and paste another place i wanna Prevent Copy if a text have fancy character like bottom
Hello ℌ
Must Skip Emojies and legal characters (Arabic & English)
How can it possible as easiest way
with the built in string function .isascii(), if the string contains anything that is not ascii, it will return false, example:
# if text is ascii or is arabic or is imojie print True else print false
text = 'هلا hala'
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568) or c.isascii() for c in text)) # True
text = ' موز '
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568) or c.isascii() for c in text)) # True
text = ''
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568 ) or c.isascii() for c in text)) # True
text = 'love '
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568 ) or c.isascii() for c in text)) # True
text = 'banana'
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568 ) or c.isascii() for c in text)) # True
text = 'Hello ℌ '
print(all((ord(c) < 128709 and ord(c) > 127568) or (ord(c) < 1609 and ord(c) > 1568 ) or c.isascii() for c in text)) # False
I'll explore this a bit before giving a solution. Firstly lets look into the ASCII for normal alphabets
ord("A"), ord("Z"), ord("a"), ord("z")
(65, 90, 97, 122)
The ASCII numbers between 90 and 97 are for brackets, or other such instances if i'm not wrong.
Coming to fancy text, this is what I found.
ord("ᴇ")
7431
Hence I think its safe to say that if your string has an ASCII outside the range from before, then its probably styled, and you can put a condition to skip it.