pygsm7 is a Python package that provides functions for encoding and decoding messages using GSM 7-bit encoding. It is designed to facilitate the processing of text messages in the context of SMS and mobile communication.
It also provides two text-encoding workflows that are common in SMS and modem projects:
- Full-Unicode hex encoding and decoding through
pygsm7.encode()andpygsm7.decode() - True packed GSM 03.38 7-bit encoding and decoding through
pygsm7.encode_gsm7()andpygsm7.decode_gsm7()
- Round-trip full Unicode text, including emoji and control characters, as uppercase UTF-16BE hex
- Encode and decode packed GSM 7-bit payloads using the GSM 03.38 default and extension tables
- Keep the API small and easy to use for scripts, modem integrations, and SMS tooling
Install pygsm7 with pip:
pip install pygsm7Use encode() and decode() when you need full Unicode coverage.
import pygsm7
encoded = pygsm7.encode("Hello world")
decoded = pygsm7.decode(encoded)
print(encoded)
print(decoded)Use encode_gsm7() and decode_gsm7() for packed GSM 03.38 payloads.
import pygsm7
packed = pygsm7.encode_gsm7("Hello {world} \\u20AC")
decoded = pygsm7.decode_gsm7(packed)
print(packed)
print(decoded)Pull requests and issues are welcome. Refer to CONTRIBUTING.md.
If you discover a security vulnerability, please send an e-mail to [email protected].
This package is open-source software licensed under the MIT license.