 |
 |
Data coming back in this form, what type is it?
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
Hi,
I'm having gzip data coming back as data like this:
Code:
\x1f\x8b\x08\x00\x00\x00\x00\x00
Is this dec/bin/he/whatever?
How could I read this in, saying using PHP? fgets get stuck on this kind of data. Maybe I have to convert it to another type somehow? unpack maybe?
Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by timmerk:
Hi,
I'm having gzip data coming back as data like this:
Code:
\x1f\x8b\x08\x00\x00\x00\x00\x00
Is this dec/bin/he/whatever?
How could I read this in, saying using PHP? fgets get stuck on this kind of data. Maybe I have to convert it to another type somehow? unpack maybe?
Thanks!
It's hexadecimal (base 16). the "x" is the giveaway. The thing is, in PHP, all you have to do is print it (with echo or print). However, in the example above, the only printable character is 0x8b, which is decimal 139, and that's high-ASCII, so the value depends on the font and encoding.
[php]
$var1 = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
print $var1;
[/php]
In the sequence you have there though, you print chr(31), chr(139), chr(8), and a bunch of chr(0), which is null. If you look at an ASCII table, you'll see that chr(31) is a non-printing character, chr(8) is a backspace, and chr(139) is effectively erased by the backspace, however it would have been rendered.
For those who are interested, base 16 counts like this:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1a, 1b, 1c, 1d, 1e, 1f, 20, 21 ...
Et cetera. Computer programmers use hexadecimal notation because you can count 8 bits (0 to 255) with two characters (00 to ff).
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
Thanks for the reply! How would I use gzlib functions in PHP to get the normal string?
Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by timmerk:
Thanks for the reply! How would I use gzlib functions in PHP to get the normal string?
Thanks!
http://us2.php.net/zlib
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|