For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2005 > Binary Large Objects (BLOB) decoding









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Binary Large Objects (BLOB) decoding
Tom Allison

2005-10-27, 9:55 pm


I'm making a crude attempt to parse through some database BLOBS with
some success. Some of the information is in XML format, some in
"text". But a lot of crud exists because of the binary characters.

I originally tried this:

my $ascii =3D unpack("A*", $blob);

but with limited success. At least it keeps the application from
crashing. But it would be really useful if I could so something along
the lines of replacing certain key combinations with a simple '\n'
or similar.

I'm also not exactly sure what the characters are that I'm seeing.
'less' says that a lot of them are <C0><80> which don't appear be on
my ascii table of characters....

help?
I'm reasonably certain that pack/unpack can do this, but I'm not sure
how.
John W. Krahn

2005-10-27, 9:55 pm

Tom Allison wrote:
> I'm making a crude attempt to parse through some database BLOBS with
> some success. Some of the information is in XML format, some in
> "text". But a lot of crud exists because of the binary characters.
>
> I originally tried this:
>
> my $ascii = unpack("A*", $blob);


The only modification the "A*" format does is remove trailing whitespace.


> but with limited success. At least it keeps the application from
> crashing. But it would be really useful if I could so something along
> the lines of replacing certain key combinations with a simple '\n'
> or similar.


You probably need to use either the substitution or transliteration operators.


> I'm also not exactly sure what the characters are that I'm seeing.
> 'less' says that a lot of them are <C0><80> which don't appear be on
> my ascii table of characters....


That is because ASCII only refers to the characters in the range 0x00 - 0x7F.



John
--
use Perl;
program
fulfillment
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com