Calculate the length that Twitter will consider a Tweet to be
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+2037as each taking up 2 characters
pip3 install tweet-counter
from tweet_counter import count_tweet
print(count_tweet("Otters 👪 otters 𝗼𝘁𝘁𝗲𝗿𝘀 otters otters.com/otters"))
# Output => 60
$ count-tweet "Otters 👪 otters 𝗼𝘁𝘁𝗲𝗿𝘀 otters otters.com/otters"
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.