G'day, monks. I've been playing with SQLite alot lately, and I'm trying to find a way to add binary attachments to the database. The SQLite docs recommend Base64 encoding, so I thought I'd experiment with that a bit.
Here's my program to encode files in Base64:
#! /usr/bin/perl use strict; use MIME::Base64 qw( encode_base64 ); use IO::All; encode_base64( io( $ARGV[0] )->slurp ) > io( $ARGV[1] ); __END__
And the matching decode program:
#! /usr/bin/perl use strict; use MIME::Base64 qw( decode_base64 ); use IO::All; decode_base64( io( $ARGV[0] )->slurp ) > io( $ARGV[1] ); __END__
Here's what I tried to test it:
Z:\>perl encode_base64.pl yearsinservice.pdf yis.b64 Z:\>perl decode_base64.pl yis.b64 yis.pdf
When I try to open yis.pdf with Acrobat Reader, it says there's an error in the file. The original PDF works fine. Any suggestions?
UPDATE: I moved these PDFs to my Linux box and used hexdump -C to look at them - it looks like an endline issue (yis.pdf has Windows-style endlines). I tried adding local $/ = "\n"; to each file, but that didn't seem to help.
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
In reply to Problem Encoding/Decoding PDF with MIME::Base64 by DamnDirtyApe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |