Revised calcLength() function
Brought to you by:
sephiroth_tmm
I found it necessary to change the 3 ord value
comparisions in the if conditional in the calcLength()
function from:
1024 to 2048
32768 to 65536
2097152 to 1114112
So the new revised calcLength() function is as follows:
// --- Revised function [begin] -----------------------
private function calcLength(struct:String)
{
var c;
var result=0;
var l = struct.length;
for (var i=0; i < l; i++)
{
c = ord(struct.charAt(i));
if(c<128) {
result += 1;
} else if (c<2048) {
result += 2;
} else if (c<65536) {
result += 3;
} else if (c<1114112) {
result += 4;
}
}
return result;
}
// --- Revised function [end] -------------------------