انضم إلى نوستر
2026-05-18 01:19:12 UTC

wono on Nostr: /run py def encode_secret_emoji(emoji: str, text: str) -> str: """Encode text to ...

/run py

def encode_secret_emoji(emoji: str, text: str) -> str:
"""Encode text to Secret Emoji"""
VS_START = 0xfe00
VS_SUPP_START = 0xe0100

utf8_bytes = text.encode('utf-8')
result = []

for byte in utf8_bytes:

if byte <= 15:
cp = VS_START + byte
else:
cp = VS_SUPP_START + byte - 16
result.append(chr(cp))

return emoji + ''.join(result)


def decode_secret_emoji(text: str) -> str:
"""Decode Secret Emoji to text"""
VS_START, VS_END = 0xfe00, 0xfe0f
VS_SUPP_START, VS_SUPP_END = 0xe0100, 0xe01ef

decoded = []
i = 0

while i < len(text):
cp = ord(text[i])

if 0xD800 <= cp <= 0xDBFF and i + 1 < len(text):
low = ord(text[i + 1])
if 0xDC00 <= low <= 0xDFFF:
cp = 0x10000 + ((cp - 0xD800) << 10) + (low - 0xDC00)
i += 2
else:
i += 1
continue
else:
i += 1

if VS_START <= cp <= VS_END:
decoded.append(cp - VS_START)
elif VS_SUPP_START <= cp <= VS_SUPP_END:
decoded.append(cp - VS_SUPP_START + 16)
return bytes(decoded).decode('utf-8', errors='replace')


print(decode_secret_emoji("👙󠇓󠅳󠆆󠇓󠅳󠆙󠇠󠆏󠆕󠆏󠇣󠆐󠅷󠆃󠇣󠆐󠅵󠆡󠇣󠆐󠅵󠆪󠇣󠆐󠅷󠆃󠇣󠆐󠅵󠆡󠇣󠆐󠅶󠆃󠇣󠆐󠅷󠆃󠇣󠆐󠅵󠆡󠇣󠆐󠅶󠆑󠇣󠆐󠅷󠆃󠇣󠆐󠅵󠆡󠇣󠆐󠅵󠆤"))