TAdvTwitter - Message Validation

I know that the max length is 140 or 117 if you add a picture, but there seems to be other rules as well. For example if you compose a message in Twitter as soon as you type a.co or a.tv etc. the character count drops by 18.

So is there a specific algorithm that can be used to generate the effective character count of a string rather than just the adding up then number of characters.

At this moment there is no such algorithm built-in in TAdvTwitter. We'll need to checkup if there are specific rules, but I'd guess that the total nr. of characters with shortened URLs would still be 140.

That's true, but my problem is if I have 140 characters of text and within that text there is something like a.co, the message will not be sent. As soon as you type a.co the character limit drops by 18.

I guess this is Twitter interpreting this as t.co-wrapped links, explained here:

If what you write is not a link, I'd guess that this is perhaps misinterpreted by Twitter?

Yes this is the problem. Twitter knows the rules for characters counting and twitter will only send the text if the final count (by its calculation) is <= 140 or 117 with a picture. If you type some text in Twitter, you can see the character count jumping all over the place as it tries to determine if what you have typed is a URL. There is an IANA list of extensions which you can use to help this process but even this is not as simple as you might think. If the URL does not start with https, http or www then a subset of this list applies.

I am endeavouring to create a routine which parses a string and returns the effective number of characters.