getting String filesize in Coldfusion

Sometimes one needs to get the filesize of a string. For example when one wants to write this string into an Amazon SQS where there is a maximum limit of 256KB.

private numeric function getStringByteSize(required string text) {
 return ArrayLen( arguments.text.getBytes("UTF-8") );
}

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s