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