full explanation:
I'm working on a project to generate twitter links that post over to twitter. My problem is twitter doesn't shorten the text correctly, and asks the user to fix the text. So I'm going to have javascript shorten the text to the maximum allowed without the extra being cut off by the user or twitter.
That's an unknown number because bitly will add characters as the namespace runs out. So it might be 21 today but 22 in a year. You may need to create the bitly links yourself before posting to Twitter.