Skip to main content

Python library for creating GSM-7 compatible SMS messages

Project description

Python library for creating GSM-7 compatible SMS messages

Installation

pip install py-smsify

Standalone Functions

from py_smsify import SmsMessage

# Encode python string into a GSM-7 python encoded string
SmsMessage.encode(string: str) -> str

# Encode a unicode string to a bytearray of SMS characters
SmsMessage.message_encode(string: str) -> bytearray

Usage

from py_smsify import SmsMessage

#Encode to a string of valid characters
message = SmsMessage("Cool Message!").encoded_text
# result: Cool Message!

#Encode to a python bytestring
message = SmsMessage("Cool Message!").encoded_bytes
# result: b"Cool Message!"

#Encode with non latin languages/characters
message = SmsMessage("酷短信!").encoded_text
# result: KuDuanXin!

#Encode with emojis
message = SmsMessage("Cool😎 Message✉️").encoded_text
# result: "Cool:sunglasses: Message:envelope:"

Message Stats

from py_smsify import SmsMessage

#Get message length in bytes
message = SmsMessage("Cool Message!").length
# result: 13 bytes
message = SmsMessage("He\\o W{}rld!").length #{} are characters from the extended table and therefore require 2 bytes of space
# result: 15 bytes

#Get amount of segments the message will be split to
message = SmsMessage("Cool Message!").segments
# result: 1 message

#You can also have it calculate segment count with twilio message headers in mind
message = SmsMessage("Cool Message!",twilio=True).segments
# result: 1 message

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-smsify-0.2.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

py_smsify-0.2.1-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page