EBook-Ishmael
view release on metacpan or search on metacpan
#include "ppport.h"
#define DECODE_BUF_SIZE 8192
// https://wiki.mobileread.com/wiki/PalmDOC#PalmDoc_byte_pair_compression
int
c_palmdoc_decode(
const unsigned char* input, STRLEN inlen,
unsigned char* output, STRLEN outlen,
STRLEN* decoded
) {
unsigned int b = 0;
unsigned int ld = 0;
unsigned int l, d = 0;
STRLEN outp = 0;
*decoded = 0;
for (STRLEN i = 0; i < inlen;) {
b = input[i++];
// space + xor byte with 0x80
if (b >= 0xc0) {
if (outp >= outlen) {
return -1;
}
output[outp++] = ' ';
if (outp >= outlen) {
} else {
if (outp >= outlen) {
return -1;
}
output[outp++] = '\0';
}
}
assert(outp <= outlen);
*decoded = outp;
return 0;
}
MODULE = EBook::Ishmael PACKAGE = EBook::Ishmael::Decode
PROTOTYPES: DISABLE
SV*
xs_palmdoc_decode(encode)
lib/EBook/Ishmael/Decode.pm view on Meta::CPAN
B<EBook::Ishmael::Decode> is a module that provides subroutines for decoding
various kinds of encoded ebook text. For L<ishmael> user documentation, you
should consult its manual (this is developer documentation).
=head1 SUBROUTINES
B<EBook::Ishmael::Decode> does not export any subroutines by default.
=head2 $d = palmdoc_decode($data)
Decodes PalmDoc lz77-encoded C<$data>, returning the decoded data.
=head1 AUTHOR
Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>.
This project's source can be found on its
L<Codeberg Page|https://codeberg.org/1-1sam/ishmael>. Comments and pull
requests are welcome!
=head1 COPYRIGHT
lib/EBook/Ishmael/MobiHuff.pm view on Meta::CPAN
=over 4
=item $mh = EBook::Ishmael::MobiHuff->new($huff, @cdics)
Returns a blessed C<EBook::Ishmael::MobiHuff> object and reads Huff/CDIC data
from C<$huff> and C<@cdics>. C<$huff> is the record data for the C<HUFF> record,
C<@cdics> is an array of record data for eacah C<CDIC> record.
=item $data = $mh->decode($encode)
Returns the decoded C<$data> from C<$encode>.
=back
=head1 AUTHOR
Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>.
This project's source can be found on its
L<Codeberg Page|https://codeberg.org/1-1sam/ishmael>. Comments and pull
requests are welcome!
( run in 1.855 second using v1.01-cache-2.11-cpan-9383018d099 )