💾 Archived View for sdf.org › blippy › py.gmi captured on 2024-06-16 at 12:34:23. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-03-21)

-=-=-=-=-=-=-

PYTHON

Created 2023-08-10

Text to binary

Create foo.py:

import sys
s = sys.argv[1]
b = s.encode('latin-1').decode('unicode_escape').encode('utf-8')
print(b)
print(len(b))

Invoke:

python3 ./foo.py "HI\x01\x00\x02"

Output:
b'HI\x01\x00\x02'
5

Reddit discussion