betoneto 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("🥟󠇓󠅱󠅶󠇓󠅱󠆛󠇓󠅲󠅵󠇓󠅱󠅶󠇓󠅰󠅱󠇗󠆚󠅱󠇗󠅴󠆦󠇓󠅱󠆞󠇓󠅱󠅺󠇓󠅱󠆓󠇓󠅱󠆡󠇓󠅱󠅴󠇓󠅱󠆞󠇕󠆒󠆃󠇓󠅲󠆂󠇗󠆙󠅽󠇓󠅲󠆃󠇓󠅱󠆗")))
Published at
2026-05-18 02:02:53 UTCEvent JSON
{
"id": "6492add9ece769e251f62ab709e1df7699406cc6d01b67a468b559b139c0e1fc",
"pubkey": "21ac29561b5de90cdc21995fc0707525cd78c8a52d87721ab681d3d609d1e2df",
"created_at": 1779069773,
"kind": 1,
"tags": [
[
"client",
"nokakoi",
"31990:21ac29561b5de90cdc21995fc0707525cd78c8a52d87721ab681d3d609d1e2df:1760607697586",
"wss://yabu.me"
]
],
"content": "/run py\n\ndef encode_secret_emoji(emoji: str, text: str) -\u003e str:\n \"\"\"Encode text to Secret Emoji\"\"\"\n VS_START = 0xfe00 \n VS_SUPP_START = 0xe0100 \n \n utf8_bytes = text.encode('utf-8')\n result = []\n\n for byte in utf8_bytes:\n \n if byte \u003c= 15:\n cp = VS_START + byte \n else:\n cp = VS_SUPP_START + byte - 16 \n result.append(chr(cp))\n\n return emoji + ''.join(result)\n\n\ndef decode_secret_emoji(text: str) -\u003e str:\n \"\"\"Decode Secret Emoji to text\"\"\"\n VS_START, VS_END = 0xfe00, 0xfe0f \n VS_SUPP_START, VS_SUPP_END = 0xe0100, 0xe01ef \n\n decoded = []\n i = 0\n\n while i \u003c len(text):\n cp = ord(text[i])\n\n if 0xD800 \u003c= cp \u003c= 0xDBFF and i + 1 \u003c len(text):\n low = ord(text[i + 1])\n if 0xDC00 \u003c= low \u003c= 0xDFFF:\n cp = 0x10000 + ((cp - 0xD800) \u003c\u003c 10) + (low - 0xDC00)\n i += 2\n else:\n i += 1\n continue\n else:\n i += 1\n\n if VS_START \u003c= cp \u003c= VS_END:\n decoded.append(cp - VS_START) \n elif VS_SUPP_START \u003c= cp \u003c= VS_SUPP_END:\n decoded.append(cp - VS_SUPP_START + 16) \n return bytes(decoded).decode('utf-8', errors='replace')\n\nprint(decode_secret_emoji(\"🥟󠇓󠅱󠅶󠇓󠅱󠆛󠇓󠅲󠅵󠇓󠅱󠅶󠇓󠅰󠅱󠇗󠆚󠅱󠇗󠅴󠆦󠇓󠅱󠆞󠇓󠅱󠅺󠇓󠅱󠆓󠇓󠅱󠆡󠇓󠅱󠅴󠇓󠅱󠆞󠇕󠆒󠆃󠇓󠅲󠆂󠇗󠆙󠅽󠇓󠅲󠆃󠇓󠅱󠆗\")))",
"sig": "a735ac8e3cb54f61d64871c1ddf3316414893bec883bb68dffb066865c23e3781e2344b9e5e155f473b38822a6fb261c731d6d95850ce38f452b8dddf055e2db"
}