{"id":8694,"library":"t61codec","title":"Python Codec for ITU T.61 Strings","description":"t61codec is a Python library that provides a codec for handling ITU T.61 character strings. It allows encoding Python strings into T.61 byte sequences and decoding T.61 byte sequences back into Python strings. The current version is 2.0.0 and it maintains a semantic versioning release cadence, though updates are infrequent.","status":"active","version":"2.0.0","language":"en","source_language":"en","source_url":"https://github.com/exhuma/t61codec","tags":["codec","t.61","itu-t","encoding","decoding"],"install":[{"cmd":"pip install t61codec","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The 't.61' codec is not available by default in the standard 'codecs' module until `t61codec.register()` is explicitly called.","wrong":"import codecs\ncodecs.encode('hello', 't.61')","symbol":"t61codec","correct":"import t61codec\nt61codec.register()"}],"quickstart":{"code":"import t61codec\nimport codecs\n\nt61codec.register()\n\n# Encode a Python string to T.61 bytes\npython_string = \"Hello, World!\"\nt61_bytes = codecs.encode(python_string, 't.61')\nprint(f\"Encoded: {t61_bytes!r}\")\n\n# Decode T.61 bytes back to a Python string\ndecoded_string = codecs.decode(t61_bytes, 't.61')\nprint(f\"Decoded: {decoded_string}\")\n\n# Example with characters that might be specific to T.61 (if applicable)\n# For simplicity, using basic ASCII characters as T.61 is an 8-bit encoding\n# For specific non-ASCII T.61 characters, consult ITU-T T.61 standard.","lang":"python","description":"This quickstart demonstrates how to register the t61codec and then use Python's built-in `codecs` module to encode and decode strings using the 't.61' encoding."},"warnings":[{"fix":"Always call `t61codec.register()` once at the start of your application or before the first use of the 't.61' encoding.","message":"The `t.61` codec must be explicitly registered with Python's `codecs` registry before it can be used. Forgetting to call `t61codec.register()` will result in a `LookupError` when trying to use the 't.61' encoding.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that input strings only contain characters representable in T.61 or implement appropriate error handling (e.g., `'replace'`, `'ignore'`) when encoding.","message":"ITU T.61 is an 8-bit encoding. While it can represent some non-ASCII characters, it has a limited character set compared to modern encodings like UTF-8. Attempting to encode characters not supported by T.61 will raise a `UnicodeEncodeError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `t61codec.register()` at the beginning of your script or before attempting to use the 't.61' encoding.","cause":"The `t61codec` library has not been registered with Python's `codecs` module.","error":"LookupError: unknown encoding: t.61"},{"fix":"Filter out or replace unsupported characters before encoding, or specify an error handler like `errors='replace'` or `errors='ignore'` in the `encode` call (e.g., `codecs.encode(my_string, 't.61', errors='replace')`).","cause":"The input string contains a Unicode character (e.g., Euro sign '€') that is not supported by the ITU T.61 encoding.","error":"UnicodeEncodeError: 't.61' codec can't encode character '\\u20ac' in position X: character maps to <undefined>"}]}