There are two ways I can think of.
You will need a Tcl proc and I think this could be done either in a Tps proc or in an xltp proc (this one I am not sure of).
You need to get the message from the message handle.
Once you have that in a variable, you can either:
Do a string bytelength
or
Do a string length
The difference is that if UTF is in use the bytelength will give you the actual number of bytes (that might be important and would be different than what string length returns), string length on the other hand returns the number of characters no matter how many bytes of storage are actually consumed.
So if a character in UTF takes 3 bytes and you have a single character message, bytelength would return 3 and length would return 1. Both would be correct but with different meanings.
If it were me, given the scenario you posted, I would use bytelength.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.