tweet-counter

Calculate the length that Twitter will consider a Tweet to be


Install
pip install tweet-counter==0.1.0

Documentation

Tweet counter

Calculate the size that Twitter will consider a tweet to be.

This is not as advanced as the official twitter-text libraries, but attempts to at least take into account the following:

  • Twitter will convert anything that looks like a URL (with a valid TLD) into a Twitter short link, and count it as taking up exactly 23 characters
  • Twitter counts emoji and any unicode character above U+2037 as each taking up 2 characters

Installation

pip3 install tweet-counter

Python usage

from tweet_counter import count_tweet

print(count_tweet("Otters πŸ‘ͺ otters π—Όπ˜π˜π—²π—Ώπ˜€ otters otters.com/otters"))
# Output => 60

Command-line usage

$ count-tweet "Otters πŸ‘ͺ otters π—Όπ˜π˜π—²π—Ώπ˜€ otters otters.com/otters"
60