Skip to content

Sweego-io/python-sms-counter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS Counter

python-sms-counter is a lib that help to count characters of SMS messages.

How to use it

from sms.counter import SMSCounter
>>> counter = SMSCounter ();
>>> counter.count ( 'ǂ some-string-to-be-counted' ).dict ();
>>> {'length': 29, 'messages': 1, 'remaining': 41, 'per_message': 70, 'encoding': 'UTF16'}
>>> {'chars_per_segment': 70,
     'chars_remaining': 43,
     'content': 'ǂ some-string-to-be-counted',
     'encoding': 'UTF16',
     'max_chars_available': 70,
     'segment': 1,
     'sms_size': 27}

The meaning of the sms_size, chars_remaining and chars_per_segment values returned by count() depend on the encoding.

For GSM_7BIT_EX encoding, sms_size, chars_remaining and chars_per_segment count the number of 7-bit characters in the message, including the escape character that must precede any characters in the "extended" character set. For example, the sms_size of the message '€' is 2, because it takes 2 7bit characters to encode '€' in GSM_7BIT_EX.

For UTF16 and GSM_7BIT encoding, sms_size, chars_remaining and chars_per_segment count the number of characters (since all characters have an equal bit width).

All GSM_7BIT & GSM_7BIT_EX characters list : https://en.wikipedia.org/wiki/GSM_03.38

Mentions

License

MIT licensed. See the bundled LICENSE file for more details.

Support

  • Python : >=3.9

About

SMS Character Counter for Python 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.9%
  • Makefile 5.1%