...

View Full Version : Measuring the length of a gz string



MattF
01-27-2010, 08:03 PM
Does anyone have any suggestions as to whether, (and if so how), measuring the byte length of a gzencoded string is possible, without writing it to a flatfile and using filesize or suchlike. I'll be damned if I can figure/find a way to do it. :D


Cheers.

kbluhm
01-27-2010, 08:11 PM
The above?

Did you have code to show us that you forgot to include? ;)

MattF
01-27-2010, 08:17 PM
The above?

Did you have code to show us that you forgot to include? ;)

Nope. No code. I was referring to the title line. :D I'll edit the first post to make that a bit less vague in meaning. :) It's just a simple gz encoded string I'm trying to find the size of. To use the example below:



$input = 'Some input here';
$output = gzencode($input);


how might one find the byte length of the $output string?

JAY6390
01-27-2010, 08:44 PM
echo strlen(gzdecode($output)); perhaps?

MattF
01-27-2010, 09:56 PM
echo strlen(gzdecode($output)); perhaps?

Nope. That don't work. :D Already tried that one and every other suggestion I've found so far. mbstrlen with encoding set to Latin, etc doesn't work either. It's to determine the filesize for a Content-Length: header, but every method I've tried so far comes nowhere near to what the browser reports as being the filesize.

kbluhm
01-28-2010, 01:38 AM
This is nowhere near tested, but would this work?


ob_start();
echo $gz_string;
$length = ob_get_length();
ob_end_clean();

MattF
01-28-2010, 01:54 AM
This is nowhere near tested, but would this work?


ob_start();
echo $gz_string;
$length = ob_get_length();
ob_end_clean();


To perfection, it would appear. :) You're an absolute star. :thumbsup: I've spent several days on this one and I got absolutely nowhere fast. :D Thanks ever so much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum