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