code: function UTF8Length(input) {
  		var output = 0;
  		for (var i = 0; i<input.length; i++) 
  		{
  			var charCode = input.charCodeAt(i);
  				if (charCode > 0x7FF)
  				   {
  					  // Surrogate pair means its a 4 byte character
  					  if (0xD800 <= charCode && charCode <= 0xDBFF)
  						{
  						  i++;
  						  output++;
  						}
  				   output +=3;
  				   }
  			else if (charCode > 0x7F)
  				output +=2;
  			else
  				output++;
  		} 
  		return output;
  	}
docs: Takes a String and calculates its length in bytes when encoded in UTF8.
  @private