Skip to content

Commit

Permalink
Merge pull request #2 from ranwitter/bugfix/rt_148220
Browse files Browse the repository at this point in the history
fixes #1, added header to indicate huffman encoding
  • Loading branch information
ranwitter authored Aug 24, 2023
2 parents 4779e40 + ef2ec40 commit 97942a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Version 0.02
print "\nhttp://www.plantuml.com/plantuml/txt/$encoded";

# Output
http://www.plantuml.com/plantuml/uml/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/png/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/svg/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/txt/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/uml/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/png/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/svg/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/txt/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700

=head1 EXPORT

Expand Down
20 changes: 15 additions & 5 deletions lib/UML/PlantUML/Encoder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ our $VERSION = '0.02';
print "\nhttp://www.plantuml.com/plantuml/txt/$encoded";
# Output
http://www.plantuml.com/plantuml/uml/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/png/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/svg/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/txt/69NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/uml/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/png/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/svg/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
http://www.plantuml.com/plantuml/txt/~169NZKe00nvpCv5G5NJi5f_maAmN7qfACrBoIpEJ4aipyF8MWrCBIrE8IBgXQe185NQ1Ii1uiYeiBylEAKy6g0HPp7700
=head1 EXPORT
Expand Down Expand Up @@ -165,6 +165,16 @@ sub encode64 {
return $str;
}

=head2 add_header_huffman
To Indicate that this is Huffman Encoding add an header ~1.
=cut

sub add_header_huffman {
return '~1' . $_[0];
}

=head2 encode_p
Encodes diagram text descriptions
Expand All @@ -174,7 +184,7 @@ Encodes diagram text descriptions
sub encode_p {
my $data = utf8_encode( $_[0] );
my $compressed = _compress_with_deflate( $data, 9 );
return encode64($compressed);
return add_header_huffman(encode64($compressed));
}

=head1 AUTHOR
Expand Down
2 changes: 1 addition & 1 deletion t/01-encode.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Bob --> Alice: Authentication Response
#diag $encoded;

ok( $encoded eq
'69NZSip9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G3PV1em',
'~169NZSip9J4vLqBLJSCfFib9mB2t9ICqhoKnEBCdCprC8IYqiJIqkuGBAAUW2rO0LOr5LN92VLvpA1G3PV1em',
'Encoding works'
);

0 comments on commit 97942a0

Please sign in to comment.